5 people like it.

Either in F#

Had to throw together a Haskell-style Either type in F# since Choice is a pain in the ass.

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
[<AutoOpen>]
module Either

type Either<'a, 'b> =
    | Left of 'a
    | Right of 'b

type either<'a, 'b> =
    Either<'a, 'b> // lower-case alias like option
Multiple items
type AutoOpenAttribute =
  inherit Attribute
  new : unit -> AutoOpenAttribute
  new : path:string -> AutoOpenAttribute
  member Path : string

Full name: Microsoft.FSharp.Core.AutoOpenAttribute

--------------------
new : unit -> AutoOpenAttribute
new : path:string -> AutoOpenAttribute
Multiple items
module Either

--------------------
type Either<'a,'b> =
  | Left of 'a
  | Right of 'b

Full name: Either.Either<_,_>
type Either<'a,'b> =
  | Left of 'a
  | Right of 'b

Full name: Either.Either<_,_>
union case Either.Left: 'a -> Either<'a,'b>
union case Either.Right: 'b -> Either<'a,'b>
type either<'a,'b> = Either<'a,'b>

Full name: Either.either<_,_>

More information

Link:http://fssnip.net/ji
Posted:11 years ago
Author:Bryan Edds
Tags: f# , either