take 3 $ many $ Just 1
doesn't type check. Did you mean this?
take 3 <$> (many $ Just 1)
I think this may have something to do with the default definition of many in the definition of Alternative:
many :: f a -> f [a]
many v = many_v
where
many_v = some_v <|> pure []
some_v = (fmap (:) v) <*> many_v
many_v and some_v are mutually recursive functions, and it may be that this prevents the thunks from being made available to take in some way. I'm really not sure though, this is just an idea about why this is not quite the same as (take $ repeat 1)
It seems that some and many are usually used in a context where something is consumed, and can be depleted, so the loop ends.
But why doesn't this terminates?
It's a recursive call, but the construction of the result should be lazy...
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafeOnly members subscribed via the mailman list are allowed to post.