[Haskell-cafe] Info about List with terminal element

Silvio Frischknecht silvio.frischi at gmail.com
Wed Nov 25 19:00:32 UTC 2015


Hello,

I'm interested in learning more about a list-like structure with a
terminal element. I.e.

data List t e = Cons e (List t e) | Null t

or maybe

data List t e = Cons e (List t e) | Null | Terminal t


An practical application could be lazy reading from a file
readFile :: String -> List Error String

Obviously there is a Functor instance. There is even a Monad instance.
However, it is not defined as obviously because it's not clear what the
terminal element should be. There is a straight forward fold like structure.

My questions are.

Are there more interesting generalizations of List?
What rules do they follow?
How should the Monad work? Why?

I know this is related to the whole Iteratee discussion (I'm not
completely familiar with it).

Cheers

Silvio


More information about the Haskell-Cafe mailing list