[Haskell-cafe] Are there standard idioms for lazy, pure error handling?

David Menendez dave at zednenem.com
Fri Dec 4 14:29:40 EST 2009


On Fri, Dec 4, 2009 at 1:14 PM, Jason McCarty <jmccarty at sent.com> wrote:
> wren ng thornton wrote:
>
>>     concat1 :: T a b -> (b -> T a b) -> T a b
>
> This could just as easily be
>
>  concat :: T a b -> (b -> T a c) -> T a c
>
> right? It's a little weird to call this concatenation, but I bet it
> could come in handy.

T a is, among other things, the free monad for the functor (,) a. The
concat you describe is the monadic bind.

data T a b = D b | W a (T a b)

instance Monad (T a) where
    return = D

    D b >>= f = f b
    W a t >>= f = W a (t >>= f)

-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Haskell-Cafe mailing list