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

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=

If you write the literal in a string, apply 'read' and specify the type,
then it should work.
If you write it in a string literal, then it might be that you need to use
defaulting to get it to evaluate to Crust.
If you write just a bare <...> in ghci then afaik that won't ever work, as
there's a fixed set of literals ghc's parser accepts.
On Jan 27, 2016 9:44 PM, "martin"
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= _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (2)
-
Carl Eyeinsky
-
martin