[Haskell-cafe] a newbie's question

Paul Hudak paul.hudak at yale.edu
Thu Apr 21 11:03:58 EDT 2005

Thomas Davie wrote:
> On Apr 21, 2005, at 3:47 PM, SCOTT J. wrote:
>> Hi,
>> I'm beginning to study Haskell, For the following
>> a = [1,2,3]
>> b = "there"
>> do x <- a
>>    y <- b
>>    return (x , y)
>> Winhugs cannot run it. Gives
>> Syntax error in input (unexpected backslash (
>> lambda))
> Your problem is that you're using monads to grab the contents of a  and 
> b, while a and b are not monadic... You probably if you're only  just 
> setting out don't want to pay attention to any of the do  notation or 
> monadic code.  To get the result it looks like you want,  all you need 
> to do is this:
> (a, b)
> you can then define this as a new constant:
> c = (a, b)
> Hope that helps
> Bob

On the other hand, perhaps he wanted all possible combinations of values 
in the lists a and b.  Since a list is a monad, this, for example, works 

a = [1,2,3]
b = "there"
abs = do x <- a
          y <- b
          return (x,y)

In Hugs:
abs ==>


More information about the Haskell-Cafe mailing list