But what is the inferred type for
f x = do { [v] <- x, return v }
I think the proposal is to have a MonadFail constraint.
As far as I understand what you are saying, it would make sense for
f :: Monad m => m [a] -> m a
g x = do { [v] <- x; return v }
(with failure giving a runtime error).
From: Libraries [mailto:libraries-bounces@haskell.org]
On Behalf Of Johan Tibell
Sent: 10 June 2015 14:01
To: Mario Blažević
Cc: Haskell Libraries
Subject: Re: MonadFail proposal (MFP): Moving fail out of Monad
An idea. Could the new desugaring be the same as for normal functions with a missing case? Code that uses fail would have to add the constraint still, but code that really didn't want to use fail would 1) get a warning about an incomplete pattern match and
2) get a runtime error for the failed pattern match produced by GHC. Is there anything I'm not thinking of here why this wouldn't work?