Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  QuickCheck for testing a parsing function (Henk-Jan van Tuyl)
   2. Re:  Need help with HXT (Michael Orlitzky)
   3. Re:  Need help with HXT (Philippe Sismondi)
   4.  Print values stored in an "Either" in the main   method
      (Mathew Phillips)
   5. Re:  Print values stored in an "Either" in the main method
      (David McBride)
   6. Re:  Print values stored in an "Either" in the main method
      (Mathew Phillips)


----------------------------------------------------------------------

Message: 1
Date: Thu, 20 Feb 2014 14:39:33 +0100
From: "Henk-Jan van Tuyl" <[email protected]>
To: [email protected], "Thomas Bach"
        <[email protected]>
Subject: Re: [Haskell-beginners] QuickCheck for testing a parsing
        function
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
        delsp=yes

On Sun, 16 Feb 2014 10:45:21 +0100, Thomas Bach
<[email protected]> wrote:

> Hi there,
>
> I have the following snippet:
:
> Any hints? Or is this simply not a nail for the QuickCheck-hammer?

I am not a QuickCheck expert, but I think you need to generate the parts  
that you expect as output, than compose these parts into the string to be  
parsed. That way, you can check the result.

Regards,
Henk-Jan van Tuyl


-- 
Folding@home
What if you could share your unused computer power to help find a cure? In
just 5 minutes you can join the world's biggest networked computer and get
us closer sooner. Watch the video.
http://folding.stanford.edu/


http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--


------------------------------

Message: 2
Date: Thu, 20 Feb 2014 13:49:18 -0500
From: Michael Orlitzky <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Need help with HXT
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

On 02/16/2014 09:34 AM, Philippe Sismondi wrote:
> 
> Attribute list
> used for storing option lists and features of DTD parts
> 
> So, I am clearly missing something - which, as usual, is probably my
> fault. What I am missing is: what goes in the attribute list for e.g.
> withCurl?
> 

I can't be sure, but the 'Attributes' type is a list of 2-tuples that
contain... something. I would try the empty list and see what happens.
For example,

  readDocument [ withCurl [] ] "http://example.com/some.xml";



------------------------------

Message: 3
Date: Thu, 20 Feb 2014 16:48:57 -0500
From: Philippe Sismondi <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Need help with HXT
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii


On 2014-02-20, at 1:49 PM, Michael Orlitzky <[email protected]> wrote:

> On 02/16/2014 09:34 AM, Philippe Sismondi wrote:
> 
> I can't be sure, but the 'Attributes' type is a list of 2-tuples that
> contain... something. I would try the empty list and see what happens.
> For example,
> 
Thanks, Michael. I can get withCurl to work when I supple an empty list, but I 
am guessing that the curl options allow more control. There is a link that 
purports to document curl and http options, but the links are broken. I 
contacted Uwe Schmidt (a prof who spearheaded development of HXT, I think). He 
replied to say that he would check into it when he has time.

I may have to plunge into the source code to see how curl and/or http actually 
get called if nobody restores the broken links.

Meanwhile thanks for the reply.

- P -

>  readDocument [ withCurl [] ] "http://example.com/some.xml";
> 
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners



------------------------------

Message: 4
Date: Thu, 20 Feb 2014 18:19:34 -0600
From: Mathew Phillips <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Print values stored in an "Either" in the
        main    method
Message-ID:
        <CAHuKxCL_o=NZBbOy1RMn0AwjRXyovQOq0D=myrc-fubexy4...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I have a module that looks like this

runEval :: (Show a) => Env -> Eval a -> Either String a
runEval = ...

data Value = IntVal Integer

main :: IO ()
main = do
    let env = Map.fromList [("x",IntVal 3)]
    result <- runEval env (eval (Plus (Var "x") (Lit 2)))
    case result of
        Left err -> putStrLn "Error: "++err
        Right (IntVal i) -> print i

when I call runEval from ghci I get back a result just fine

let env = Map.fromList [("x",IntVal 3)]
runEval env (eval (Plus (Var "x") (Lit 2)))

This outputs "Right (IntVal 5)" as I would expect. But when I try and
compile my main method I get the following error.

Couldn't match expected type `Value'
with actual type `Either t1 Value'
    In the pattern: Right (IntVal i)
    In a case alternative: Right (IntVal i) -> print i
    In a stmt of a 'do' block:
      case result of {
        Left err -> print err
        Right (IntVal i) -> print i }

I also tried using (putStrLn . either show show) result, but this gave me
the following error.

Couldn't match expected type `Either a0 b0'
with actual type `Value'
    In the first argument of `putStrLn . either show show', namely
      `result'
    In a stmt of a 'do' block: (putStrLn . either show show) result
    In the expression:
      do { let env = Map.fromList ...;
           result <- runEval3 env (eval3 (Plus (Var "x") (Lit 2)));
           (putStrLn . either show show) result }

Why is it when I try and pattern match on Either String Value it says
result is of type "Value", but when I try and use either it says result is
of type "Either String Value"?

Matt P.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140220/30717d72/attachment-0001.html>

------------------------------

Message: 5
Date: Thu, 20 Feb 2014 20:01:33 -0500
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Print values stored in an "Either" in
        the main method
Message-ID:
        <CAN+Tr40e9Swd2mMox_0Tevfy8ba-0GUbEYX6RTMW9X2a8=l...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Because you didn't put all your code, I'm not sure if this is correct, but
my best guess is that you expect runEval to return Either String a, but the
way you are using it I suspect you actually want its type to be IO (Either
String a).

Alternatively change

result <- runEval env (eval (Plus (Var "x") (Lit 2)))

to

let result = runEval env (eval (Plus (Var "x") (Lit 2)))


On Thu, Feb 20, 2014 at 7:19 PM, Mathew Phillips
<[email protected]>wrote:

> I have a module that looks like this
>
> runEval :: (Show a) => Env -> Eval a -> Either String a
> runEval = ...
>
> data Value = IntVal Integer
>
> main :: IO ()
> main = do
>     let env = Map.fromList [("x",IntVal 3)]
>     result <- runEval env (eval (Plus (Var "x") (Lit 2)))
>     case result of
>         Left err -> putStrLn "Error: "++err
>         Right (IntVal i) -> print i
>
> when I call runEval from ghci I get back a result just fine
>
> let env = Map.fromList [("x",IntVal 3)]
> runEval env (eval (Plus (Var "x") (Lit 2)))
>
> This outputs "Right (IntVal 5)" as I would expect. But when I try and
> compile my main method I get the following error.
>
> Couldn't match expected type `Value'
> with actual type `Either t1 Value'
>     In the pattern: Right (IntVal i)
>     In a case alternative: Right (IntVal i) -> print i
>     In a stmt of a 'do' block:
>       case result of {
>         Left err -> print err
>         Right (IntVal i) -> print i }
>
> I also tried using (putStrLn . either show show) result, but this gave me
> the following error.
>
> Couldn't match expected type `Either a0 b0'
> with actual type `Value'
>     In the first argument of `putStrLn . either show show', namely
>       `result'
>     In a stmt of a 'do' block: (putStrLn . either show show) result
>     In the expression:
>       do { let env = Map.fromList ...;
>            result <- runEval3 env (eval3 (Plus (Var "x") (Lit 2)));
>            (putStrLn . either show show) result }
>
> Why is it when I try and pattern match on Either String Value it says
> result is of type "Value", but when I try and use either it says result is
> of type "Either String Value"?
>
> Matt P.
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140220/e3379752/attachment-0001.html>

------------------------------

Message: 6
Date: Thu, 20 Feb 2014 19:05:51 -0600
From: Mathew Phillips <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Print values stored in an "Either" in
        the main method
Message-ID:
        <CAHuKxCJSwzn=4owvp65o_f9dhmqohtmwptex1te-uj01ecc...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Ok now I'm even more confused! That works, but I thought that "let" was for
when the value inside the do block was pure, and the <- notation when it's
inside another monad?


On Thu, Feb 20, 2014 at 7:01 PM, David McBride <[email protected]> wrote:

> Because you didn't put all your code, I'm not sure if this is correct, but
> my best guess is that you expect runEval to return Either String a, but the
> way you are using it I suspect you actually want its type to be IO (Either
> String a).
>
> Alternatively change
>
>
> result <- runEval env (eval (Plus (Var "x") (Lit 2)))
>
> to
>
> let result = runEval env (eval (Plus (Var "x") (Lit 2)))
>
>
> On Thu, Feb 20, 2014 at 7:19 PM, Mathew Phillips <
> [email protected]> wrote:
>
>> I have a module that looks like this
>>
>> runEval :: (Show a) => Env -> Eval a -> Either String a
>> runEval = ...
>>
>> data Value = IntVal Integer
>>
>> main :: IO ()
>> main = do
>>     let env = Map.fromList [("x",IntVal 3)]
>>     result <- runEval env (eval (Plus (Var "x") (Lit 2)))
>>     case result of
>>         Left err -> putStrLn "Error: "++err
>>         Right (IntVal i) -> print i
>>
>> when I call runEval from ghci I get back a result just fine
>>
>> let env = Map.fromList [("x",IntVal 3)]
>> runEval env (eval (Plus (Var "x") (Lit 2)))
>>
>> This outputs "Right (IntVal 5)" as I would expect. But when I try and
>> compile my main method I get the following error.
>>
>> Couldn't match expected type `Value'
>> with actual type `Either t1 Value'
>>     In the pattern: Right (IntVal i)
>>     In a case alternative: Right (IntVal i) -> print i
>>     In a stmt of a 'do' block:
>>       case result of {
>>         Left err -> print err
>>         Right (IntVal i) -> print i }
>>
>> I also tried using (putStrLn . either show show) result, but this gave me
>> the following error.
>>
>> Couldn't match expected type `Either a0 b0'
>> with actual type `Value'
>>     In the first argument of `putStrLn . either show show', namely
>>       `result'
>>     In a stmt of a 'do' block: (putStrLn . either show show) result
>>     In the expression:
>>       do { let env = Map.fromList ...;
>>            result <- runEval3 env (eval3 (Plus (Var "x") (Lit 2)));
>>            (putStrLn . either show show) result }
>>
>> Why is it when I try and pattern match on Either String Value it says
>> result is of type "Value", but when I try and use either it says result is
>> of type "Either String Value"?
>>
>> Matt P.
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140220/545c4523/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 68, Issue 17
*****************************************

Reply via email to