KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I found precedence and associativity is a big obstacle for me to understand what the grammar is trying to express at first glance to haskell code. For example, blockyPlain :: Monad m => m t -> m t1 -> m (t, t1) blockyPlain xs ys = xs >>= \x -> ys >>= \y -> return (x, y) By experiment, I finally got it means, blockyPlain xs ys = xs >>= (\x -> (ys >>= (\y -> return (x, y)))) instead of blockyPlain xs ys = xs >>= (\x -> ys) >>= (\y -> return (x, y)) Which works as: *Main> blockyPlain [1,2,3] [4,5,6] [(1,4),(1,5),(1,6),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6)] I can get info from ghci for (>>=) as an operator, (infixl 1 >>=). But there's no information for -> since it's not an operator. Could someone of you guys give some reference to make this grammar thing easier to grasp?
Tags (comma-separated)
Save Edits
Cancel