On Thu, Jan 24, 2013 at 9:56 PM, Simon Peter Nicholls <simon@mintsource.org> wrote:
I'd like to convert this Maybe Document to a Maybe MyType without unpacking and repacking the Maybe. Is this possible?That would be exactly
fmap :: (Document -> MyType) -> (Maybe Document -> Maybe MyType)where I've instantiated the type variables for your use case.All the small, single letters are type variables. Because they are implicitly universally quantified; you, the caller, gets to specify what you want them to be. Written out in full, it's actuallyfromBson :: forall (m :: * -> *), a. Monad m => Document -> m aHere, again specializing for your use case, fromBson probably needs to be of typefromBson :: Document -> Maybe MyTypeSo if you have a rightEres :: Maybe Documentthenfmap fromBson rightEres :: Maybe (Maybe MyType)which you could thenjoin $ fmap fromBson rightEres :: Maybe MyTypeWhat you're really after is the more idiomaticrightEres >>= fromBson :: Maybe MyTypeHTH,-- Kim-Ee
Thanks,Si
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners