[Haskell-beginners] Convert my own types to the Haskell types using typeclass

ke dou kd6ck at virginia.edu
Fri Apr 11 20:15:48 UTC 2014


Thank you very much!
That is exactly what I want.

Best,
Ke

On Fri, Apr 11, 2014 at 2:43 PM, Magnus Therning <magnus at therning.org>wrote:

> On Fri, Apr 11, 2014 at 12:50:45PM -0400, ke dou wrote:
> > instance Coercible (MyOption a) where
> >   type Return (MyOption a) = Prelude.Maybe a
> >   toHaskell (Some a) = Prelude.Just a
> >   toHaskell None = Prelude.Nothing
>
> The basic issue has been solved in another thread, but wouldn't you
> want this one to be something like this:
>
> instance Coercible a => Coercible (MyOption a) where
>     type Return (MyOption a) = Prelude.Maybe (Return a)
>     toHaskell (Some a) = Prelude.Just (toHaskell a)
>     toHaskell None = Prelude.Nothing
>
> /M
>
> --
> Magnus Therning                      OpenPGP: 0xAB4DFBA4
> email: magnus at therning.org   jabber: magnus at therning.org
> twitter: magthe               http://therning.org/magnus
>
> What gets measured, gets done.
>      -- Tom Peters
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140411/791736f8/attachment.html>


More information about the Beginners mailing list