[Haskell-cafe] Track Exceptions
Ruud Koot
r.koot at uu.nl
Thu Mar 13 17:09:10 UTC 2014
On Thu, Mar 13, 2014 at 5:54 PM, Roman Cheplyaka <roma at ro-che.info> wrote:
> Simply instantiating b with b `Throws` e gives
>
> map :: (a -> b `Throws` e) -> [a] -> [b `Throws` e]
>
> Which is actually a more useful type than the one you proposed, because it shows
> that map itself doesn't throw exceptions (so that e.g. computing length is
> safe).
>
> Assuming "Throws e" is a monad, you could use mapM instead of map to get the
> behavior you want.
>
> In fact, Throws will probably need to be an indexed monad.
>
> Roman
Yes, lazyness complicates things even further. You can pass a function
to map that produces an "exception value" of type b. These exceptions
would be attached to the elements inside the list [b] as you suggest.
But there might also be exceptional values hidden inside the spine of
the second argument of type [a]. These would need to end up in the
spine of the resulting list of type [b].
Ruud
More information about the Haskell-Cafe
mailing list