[Haskell-beginners] Is it possible to use a <> constructor in analogy to [] ?

martin martin.drautzburg at web.de
Wed Jan 27 20:40:18 UTC 2016


Hello all,

I've written my own Read and Show instances for a type, which is essentially

data Crust a = Open [a] | Closed [a]

"Show" does something like

*Main> Closed [1,2,3]
<1,2,3>
*Main> Open [1,2,3]
<1,2,3..>

And Read faithully parses each stings and turns it into a Crust again.

Problem is: when I just type <1,2,3..> in GHCi I get a "parse error on input ‘<’". However when I spell out the
custructor as above it parses it okay.

Is it possible at all to write my own <> constructor, or something like it=


More information about the Beginners mailing list