Dontdie YCH | 17 Sep 11:17 2014
Picon

How can I replace content of tag in xml file with haxml.

I'm trying to replace `CurrentURI` tag's contents using HaXml.

from,

```
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <s:Body>
    <u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
      <InstanceID>0</InstanceID>
      <CurrentURI>AAAAAAAAAAAA</CurrentURI>
      <CurrentURIMetaData/>
    </u:SetAVTransportURI>
  </s:Body>
</s:Envelope>
```

to,

```
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <s:Body>
    <u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
      <InstanceID>0</InstanceID>
      <CurrentURI>BBBBBBBBBBBBBB</CurrentURI>
      <CurrentURIMetaData/>
    </u:SetAVTransportURI>
(Continue reading)

Dániel Arató | 16 Sep 23:11 2014
Picon

What am I reinventing here

Hey guys,

I was working through 99 Haskell Problems a while back and while
refactoring my solution to Problem 9 I couldn't help feeling I was
reinventing something basic. My thinking was, this problem can be
generalized to letting a function recursively process arbitrary chunks
of a given data structure in several passes until the whole data is
consumed while some function is extracting some information in an
accumulator.

So I wrote a mini-typeclass like so:

class Exhaustible e where
    isEmpty :: e -> Bool
instance Exhaustible [a] where
    isEmpty = null

exhaust :: Exhaustible e => (e -> (b, e)) -> (a -> b -> a) -> a -> e -> a
exhaust f g z xs
    | isEmpty xs = z
    | otherwise  = let (val, rest) = f xs in
                   exhaust f g (g z val) rest

Now the solution to Problem 9 is easy to define in terms of "exhaust".

Then I thought, "Why am I treating empty as a special value again?",
and wrote this instead:

stabilize :: Eq a => (a -> (b, a)) -> (c -> b -> c) -> c -> a -> (c, a)
stabilize f g z d
(Continue reading)

Jeff C. Britton | 16 Sep 04:01 2014

ghci and randomRs

I am trying to use randomRs at the ghci prompt like so

Prelude System.Random> take 10 $ (randomRs (1, 6) newStdGen)

but I get the following error
<interactive>:16:12:
    Could not deduce (RandomGen (IO StdGen))
      arising from a use of `randomRs'
    from the context (Random a, Num a)
      bound by the inferred type of it :: (Random a, Num a) => [a]
      at <interactive>:16:1-37
    In the second argument of `($)', namely
      `(randomRs (1, 6) newStdGen)'
    In the expression: take 10 $ (randomRs (1, 6) newStdGen)
    In an equation for `it': it = take 10 $ (randomRs (1, 6) newStdGen)

I have tried a variety of options, like wrapping it in a "do" or adding type annotations.
Nothing seems to work.

-----Original Message-----
From: Beginners [mailto:beginners-bounces <at> haskell.org] On Behalf Of martin
Sent: Friday, September 12, 2014 10:05 AM
To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell
Subject: Re: [Haskell-beginners] How to add a "method" to a record

Am 09/10/2014 08:50 PM, schrieb Corentin Dupont:
> If the field "label" can be deduced from "payload", I recommend not to 
> include it in your structure, because that would be redundant.
> 
> Here how you could write it:
(Continue reading)

martin | 10 Sep 20:06 2014
Picon

How to add a "method" to a record

Hello all

if I have a record like

	data Foo pl = Foo {
	            label :: String,
	            payload :: pl
	        }

how can I create a similar type where I can populate label so it is not a plain string, but a function which
operates on
payload? Something like

	label (Foo pl) = show pl

ryan | 8 Sep 20:03 2014

hpc doctest

Hello,

Are there any known issues with doctest and hpc? 

Cabal test runs correctly, but hpc doesn't seem to see anything.  I have
tried to make some of the test fail on purpose so see it hpc would pick
it up, since there is additional output from cabal test when there is a
failure, but it doesn't help. 

--
-- test file
--
module Doctests where

import Test.DocTest

main :: IO ()
main = doctest ["-isrc", "src/Ch1.hs"]

--
-- command line
--
$ cabal test
Building DiscreteMathematicsUsingAComputer-0.1.0.0...
Preprocessing library DiscreteMathematicsUsingAComputer-0.1.0.0...
In-place registering DiscreteMathematicsUsingAComputer-0.1.0.0...
Preprocessing test suite 'doctests' for
DiscreteMathematicsUsingAComputer-0.1.0.0...
Warning: output was redirected with -o, but no output will be generated
because there is no Main module.
(Continue reading)

martin | 7 Sep 14:14 2014
Picon

Continuations vs. Values

Hello all,

in the continuation monad, I can turn a value into a Cont by means of return. Conversely I can convert a Cont
into a
value by passing id as the continuation. This dualism of Cont and plain values is well known.

The bind operator kind of(!) takes a value a and produces a new value b. This is all wrapped in Cont stuff, so the
result of bind is not really a plain a, but a Cont which takes a function from b -> r. But this is just the same dualism
as above.

Most Cont examples I've seen could much more easily be implemented with just values or calling functions on
values. Then
again there is "a poor man's concurrency" which I don't get at all. In between there is a huge gap of (my) understanding.

Can someone help me cross this gap? There must be certain things I can do with Conts which I cannot do easily with
values and functions.
KC | 3 Sep 15:01 2014
Picon

Does Haskell work on Free BSD?

Does Haskell work on Free BSD?

If not which is the better Linux to use?

--

--

Sent from an expensive device which will be obsolete in a few months! :D

Casey

<div><div dir="ltr">
<div>Does Haskell work on Free BSD?<br><br>
</div>If not which is the better Linux to use?<br clear="all"><div>
<br>-- <br><div dir="ltr">
<p dir="ltr">--<br></p>
<p dir="ltr">Sent from an expensive device which will be obsolete in a few months! :D</p>
Casey<br><br>
</div>
</div>
</div></div>
Dmitriy Matrosov | 2 Sep 21:32 2014
Picon

Check constructor's field numeric value at compile time

Hi.

I have a type

data Interval	= Seconds Float
		| MicroSeconds Int

The Float field of data constructor Seconds should be >= 1, and Int 
field of constructor MicroSeconds should be in the range from 0 to 1000000.

How can i write this constraints so they're checked at compile time, not 
at runtime?

--
     Dmitriy Matrosov
Jeremy | 2 Sep 09:27 2014
Picon

Stackage latest snapshot

I would like to point my cabal file to the latest Stackage snapshot. I seem
to recall that there is a link which will automatically resolve to this, but
I can no longer find it.

Does this link still exist? Is there a good reason for not doing so? I
understand that this will introduce a little instability, but I'm OK dealing
with that in return for not getting stuck on the same package versions forever.

Julius Gedvilas | 30 Aug 09:21 2014
Picon

Feature request: anonymous arguments

Anonymous argument (AA) is an argument without a name. 

w/o AA:
func :: a -> a -> a -> a
func aa0 aa1 aa2 = aa0 `op` aa1 `op` aa2
\aa0 aa1 aa2 -> aa0 `op` aa1 `op` aa2

w/ AA:
func :: a -> a -> a -> a
func = \0 `op` \1 `op` \2
\-> \0 `op` \1 `op` \2

AA syntax: '\n', where n is one of the (0 1 2 3 4 5 6 7 8 9). 'n' corresponds to the position of a parameter.

I think a language shouldn't force you to invent names for things that are used only once, same philosophy as with an anonymous function.

Is this feature needed? Does something like this already exist?

<div><div dir="ltr">
<div>Anonymous argument (AA) is an argument without a name.&nbsp;<br>
</div>
<div><br></div>
<div>w/o AA:<br>
</div>
<div>func :: a -&gt; a -&gt; a -&gt; a</div>
<div>func aa0 aa1 aa2 = aa0 `op` aa1 `op` aa2</div>
<div>
\aa0 aa1 aa2 -&gt; aa0 `op` aa1 `op` aa2</div>
<div><br></div>
<div>w/ AA:</div>
<div>func :: a -&gt; a -&gt; a -&gt; a</div>
<div>func = \0 `op` \1 `op` \2</div>
<div>\-&gt; \0 `op` \1 `op` \2</div>
<div><br></div>
<div>AA syntax: '\n', where n is one of the (0 1 2 3 4 5 6 7 8 9). 'n' corresponds to the position of a parameter.</div>
<div><br></div>
<div>I think a language shouldn't force you to invent names for things that are used only once, same philosophy as with an anonymous function.</div>
<div><br></div>
<div>Is this feature needed? Does something like this already exist?<br>
</div>
<div><br></div>
</div></div>
Roger Mason | 29 Aug 21:37 2014
Picon
Picon

Can't compile Diagrams tutorial example

Hello,

I have the following code from the Diagrams package tutorial:

> {-# LANGUAGE NoMonomorphismRestriction #-}
> 
> import Diagrams.Prelude
> import Diagrams.Backend.SVG.CmdLine

> main = mainWith (example :: Diagram B R2)
> example = circle 1 # fc blue
>                    # lw veryThick
>                    # lc purple
>                    # dashing [0.2,0.05] 0

I get the following error on compilation using GHC 7.6.3:

ghc --make DiagramsTutorial-2.lhs

[1 of 1] Compiling Main             ( DiagramsTutorial-2.lhs, DiagramsTutorial-2.o )

DiagramsTutorial-2.lhs:10:33:
    Could not deduce (Fractional (Measure R2))
      arising from the literal `0.2'
    from the context (TrailLike b,
                      Transformable b,
                      HasStyle b,
                      V b ~ R2)
      bound by the inferred type of
               example :: (TrailLike b, Transformable b, HasStyle b, V b ~ R2) =>
                          b
      at DiagramsTutorial-2.lhs:(7,3)-(10,43)
    Possible fix:
      add an instance declaration for (Fractional (Measure R2))
    In the expression: 0.2
    In the first argument of `dashing', namely `[0.2, 0.05]'
    In the second argument of `(#)', namely `dashing [0.2, 0.05] 0'

DiagramsTutorial-2.lhs:10:43:
    Could not deduce (Num (Measure R2)) arising from the literal `0'
    from the context (TrailLike b,
                      Transformable b,
                      HasStyle b,
                      V b ~ R2)
      bound by the inferred type of
               example :: (TrailLike b, Transformable b, HasStyle b, V b ~ R2) =>
                          b
      at DiagramsTutorial-2.lhs:(7,3)-(10,43)
    Possible fix: add an instance declaration for (Num (Measure R2))
    In the second argument of `dashing', namely `0'
    In the second argument of `(#)', namely `dashing [0.2, 0.05] 0'
    In the expression:
      circle 1 # fc blue # lw veryThick # lc purple
      # dashing [0.2, 0.05] 0

Thanks for any help.

Roger

Gmane