Trying to understand tuples and lists

ketil+haskell at ketil+haskell at
Wed Nov 5 13:47:55 EST 2003

Karthik Kumar <kaykaydreamz at> writes:

> I got get this working thanks to the fst and snd function. 

>> (x,y) <- head  [('a', 1), ('b', 2)]

You could also (possibly easier to read) do it like the above, only
use an '='

        (x,y) = head [('a', 1), ('b', 2)]

(The <- operator is used for monadic computations and list

    main = do
        x <- readFile ...


    mapFst xs = [ x | (x,y) <- xs ]


If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list