[Haskell-cafe] Type union

Richard Eisenberg eir at cis.upenn.edu
Mon Sep 15 13:38:57 UTC 2014


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


More information about the Haskell-Cafe mailing list