[Haskell-cafe] Type union
Arnaud Bailly
arnaud.oqube at gmail.com
Mon Sep 15 14:30:20 UTC 2014
Technically it is not different but it allows one to write things in a much
more compact way. And I would like the :| types to be of arbitrary size,
meaning each `in x y` invocation would inject a value at the right position
in the sum type without having to declare all the possible sizes of
coproducts. But maybe I could simply do that for some arbitrarily large
number of types....
--
Arnaud Bailly
FoldLabs Associate: http://foldlabs.com
On Mon, Sep 15, 2014 at 3:38 PM, Richard Eisenberg <eir at cis.upenn.edu>
wrote:
> On Sep 15, 2014, at 9:14 AM, Arnaud Bailly <arnaud.oqube at gmail.com> wrote:
>
> > Hello,
> > I have a somewhat similar problem, trying to achieve union types but for
> the purpose of defining the set of allowable outcomes of a function. I have
> tried naively to define a type operator a :| b and I would like to be able
> to define a function like :
> >
> > f :: Int -> Int :| String :| Bool
> > f 1 = in 1 1
> > f 2 = in 2 "foo"
> > f 3 = in 3 True
>
> How is this different from `Either Int (Either String Bool)`?
>
> Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140915/46225e0d/attachment.html>
More information about the Haskell-Cafe
mailing list