[Haskell-beginners] monad question

mike h mike_k_houghton at yahoo.co.uk
Fri Oct 13 18:15:23 UTC 2017


I have 

cap :: String -> String
cap = toUpper

rev :: String -> String
rev = reverse

then I make 

tupled :: String -> (String, String)
tupled = do
    r <- rev
    c <- cap
    return (r, c)

and to be honest, yes it’s been a long day at work, and this is coding at home rather than coding (java) at work but
I’m not sure how tupled  works!!!
My first shot was supplying a param s like this

tupled :: String -> (String, String)
tupled s = do
    r <- rev s
    c <- cap s
    return (r, c)

which doesn’t compile. But how does the first version work? How does the string to be processed get into the rev and cap functions??

Thanks

Mike






More information about the Beginners mailing list