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

Carl Eyeinsky eyeinsky9 at gmail.com
Fri Jan 29 13:22:37 UTC 2016


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" <martin.drautzburg at web.de> wrote:

> 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 at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160129/b7e04f10/attachment.html>


More information about the Beginners mailing list