[Haskell-beginners] Tagged types
David McBride
toad3k at gmail.com
Tue Oct 2 17:27:20 UTC 2018
You need to have some sort of either type.
check :: A Unchecked -> Either (A Hdf5) (A Cbf)
But you'll have to deal with the fact that it could be either of those
things throughout the rest of your program, somehow.
Another way would be to have
data CheckedType = Hdf5 | Cbf
check :: A Unchecked -> A CheckedType
But this has the same downside.
There may be some way with the singletons library, but I think that is out
of the scope of the newbies list.
On Tue, Oct 2, 2018 at 1:04 PM PICCA Frederic-Emmanuel <
frederic-emmanuel.picca at synchrotron-soleil.fr> wrote:
> > I believe you can do this with GADTs [1]
>
> I can create different constructors for the different types.
> but how can I create a function which return different type ?
>
>
> Fred
> _______________________________________________
> 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/20181002/94df7526/attachment.html>
More information about the Beginners
mailing list