Skip to content

A version of Data.Either that holds one of three possible values

License

Notifications You must be signed in to change notification settings

keera-studios/data-either3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a very simple datatype. Either3 a b c holds either an a, or a b, or a c.

Usage

Create Either3 values:

GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
Prelude> import Data.Either3
Prelude Data.Either3> let x :: Either3 Int Float Double; x = First 5
Prelude Data.Either3> let y :: Either3 Int Float Double; y = Second 5.12

Query their type:

Prelude Data.Either3> :type x
x :: Either3 Int Float Double
Prelude Data.Either3> :type y
y :: Either3 Int Float Double
Prelude Data.Either3> isFirst x
True
Prelude Data.Either3> isFirst y
False

Extract information:

Prelude Data.Either3> 5 + either3 fromIntegral realToFrac id x
10.0
Prelude Data.Either3> :type (5 + either3 fromIntegral realToFrac id x)
(5 + either3 fromIntegral realToFrac id x) :: Double

Stability

  • Status: stable
  • Build status: Build Status
  • Actively tested on GHC 7.6, 7.8 and 7.10, should work on all OSs with every Haskell compiler/interpreter.

About

A version of Data.Either that holds one of three possible values

Resources

License

Stars

Watchers

Forks

Packages

No packages published