Functor => Applicative => Monad

Yet another attempt of mine to "haskellify" my F# coding.

Copy Source
Copy Link
Tools:
  1: #r "FSharp.PowerPack.dll"
  2: 
  3: 
  4: open System
  5: 
  6: // Generic container of 'T 
  7: // Also parameterized by 'TypeClass : (new : unit -> 'TypeClass) 
  8: // to implicit get a 'TypeClass instance (like passing the type class dictionary)
  9: // The idea is to encode Type Classes with subtype polymorphism and OOP Classes 
 10: type Generic<'T, 'TypeClass when 'TypeClass : (new : unit -> 'TypeClass)> = interface end
 11: 
 12: type [<AbstractClass>] FunctorClass<'FunctorClass when 'FunctorClass :> FunctorClass<'FunctorClass> 
 13:                                                   and  'FunctorClass : (new : unit -> 'FunctorClass)>() = 
 14:     abstract FMap<'T, 'R> : ('T -> 'R) -> Generic<'T, 'FunctorClass> -> Generic<'R, 'FunctorClass>
 15: 
 16: type [<AbstractClass>] ApplicativeClass<'ApplicativeClass when 'ApplicativeClass :> ApplicativeClass<'ApplicativeClass> 
 17:                                                   and  'ApplicativeClass : (new : unit -> 'ApplicativeClass)>() = 
 18:     inherit FunctorClass<'ApplicativeClass>() 
 19:     // abstract methods
 20:     abstract Pure<'T> : 'T -> Generic<'T, 'ApplicativeClass>
 21:     abstract Apply<'T, 'R> : Generic<'T -> 'R, 'ApplicativeClass> -> Generic<'T, 'ApplicativeClass> -> Generic<'R, 'ApplicativeClass>
 22:     // Functor default implementation
 23:     override this.FMap<'T, 'R> (f : 'T -> 'R) (fa : Generic<'T, 'ApplicativeClass>) : Generic<'R, 'ApplicativeClass> = 
 24:         this.Apply (this.Pure f) fa
 25: 
 26: type [<AbstractClass>] MonadClass<'MonadClass when 'MonadClass :> MonadClass<'MonadClass> 
 27:                                               and  'MonadClass : (new : unit -> 'MonadClass)>() =
 28:     inherit ApplicativeClass<'MonadClass>() 
 29:     // abstract methods
 30:     abstract Return<'T> : 'T -> Generic<'T, 'MonadClass>
 31:     abstract Bind<'T, 'R> : Generic<'T, 'MonadClass> * ('T -> Generic<'R, 'MonadClass>) -> Generic<'R, 'MonadClass>
 32:     // Default implementations
 33:     member this.Then<'T, 'R> ((ma : Generic<'T, 'MonadClass>), (mb : Generic<'R, 'MonadClass>)) : Generic<'R, 'MonadClass> = 
 34:         this.Bind(ma, fun _ -> mb)
 35:     // Applicative default implementation
 36:     override this.Pure<'T> (value : 'T) : Generic<'T, 'MonadClass> = this.Return value
 37:     override this.Apply<'T, 'R> (mf : Generic<'T -> 'R, 'MonadClass>) (ma : Generic<'T, 'MonadClass>) : Generic<'R, 'MonadClass> =
 38:         this.Bind(mf, fun f -> this.Bind(ma, fun a -> this.Pure (f a)))
 39: 
 40: // Maybe Monad
 41: type Maybe<'T> = None | Some of 'T with
 42:     interface Generic<'T, MaybeClass> 
 43: and MaybeClass() = 
 44:     inherit MonadClass<MaybeClass>() with
 45:         override this.Return<'T>(v : 'T) = Some v :> _
 46:         override this.Bind<'T, 'R> ((m : Generic<'T, MaybeClass>), (f : ('T -> Generic<'R, MaybeClass>))) : Generic<'R, MaybeClass> = 
 47:             match m :?> _ with
 48:             | Some v -> f v
 49:             | None -> None :> _
 50: 
 51: let maybe = new MaybeClass() :> MonadClass<MaybeClass>
 52: 
 53: // List Monad 
 54: type ListMonadGeneric<'T> = ListMonadGeneric of LazyList<'T> with
 55:     interface Generic<'T, ListMonadClass>    
 56: 
 57: and ListMonadClass() = 
 58:     inherit MonadClass<ListMonadClass>() with
 59:         override this.Return<'T>(v : 'T) = ListMonadGeneric (LazyList.ofList [v]) :> _
 60:         override this.Bind<'T, 'R> ((m : Generic<'T, ListMonadClass>), (f : ('T -> Generic<'R, ListMonadClass>))) : Generic<'R, ListMonadClass> = 
 61:             let (ListMonadGeneric list) = m :?> _ in 
 62:                 ListMonadGeneric (LazyList.ofSeq <| Seq.collect (fun v -> let (ListMonadGeneric list') = (f v) :?> _ in list') list) :> _
 63: 
 64: // ZipList Applicative Functor
 65: type ListAppGeneric<'T> = ListAppGeneric of LazyList<'T> with
 66:     interface Generic<'T, ListApplicativeClass>
 67: and ListApplicativeClass() = 
 68:     inherit ApplicativeClass<ListApplicativeClass>() with
 69:         override this.Pure<'T> (v : 'T) = ListAppGeneric (LazyList.repeat v) :> _
 70:         override this.Apply<'T, 'R> (ff : Generic<'T -> 'R, ListApplicativeClass>) (fa : Generic<'T, ListApplicativeClass>) : Generic<'R, ListApplicativeClass> = 
 71:             let (ListAppGeneric listf) = ff :?> _ in 
 72:             let (ListAppGeneric list) = fa :?> _ in 
 73:                 ListAppGeneric (LazyList.map (fun (f, a) -> f a) (LazyList.zip listf list)) :> _
 74: 
 75: 
 76: //  Generic functions that operate over all Applicative Funtors
 77: [<AutoOpen>]
 78: module ApplicativeModule = 
 79: 
 80:     let pure<'T, 'ApplicativeClass when 'ApplicativeClass :> ApplicativeClass<'ApplicativeClass> 
 81:                              and  'ApplicativeClass : (new : unit -> 'ApplicativeClass)> 
 82:         (v : 'T) : Generic<'T, 'ApplicativeClass> = 
 83:         (new 'ApplicativeClass()).Pure v
 84: 
 85:     let apply<'T, 'R, 'ApplicativeClass when 'ApplicativeClass :> ApplicativeClass<'ApplicativeClass> 
 86:                                  and  'ApplicativeClass : (new : unit -> 'ApplicativeClass)> 
 87:         (ff : Generic<'T -> 'R, 'ApplicativeClass>) (fa : Generic<'T, 'ApplicativeClass>) : Generic<'R, 'ApplicativeClass> =
 88:         (new 'ApplicativeClass()).Apply ff fa
 89: 
 90:     let (<*>) ff fa = apply ff fa
 91:     let ($) f fa = pure f <*> fa
 92:     // Monoidal - pair
 93:     let (<.>) fa fb = (fun a b -> (a, b)) $ fa <*> fb
 94: 
 95: 
 96: //  Generic functions that operate over all Monads
 97: [<AutoOpen>]
 98: module MonadModule = 
 99: 
100:     let unit<'T, 'MonadClass when 'MonadClass :> MonadClass<'MonadClass> 
101:                              and  'MonadClass : (new : unit -> 'MonadClass)> 
102:         (v : 'T) : Generic<'T, 'MonadClass> = 
103:         (new 'MonadClass()).Return v
104: 
105:     let bind<'T, 'R, 'MonadClass when 'MonadClass :> MonadClass<'MonadClass> 
106:                                  and  'MonadClass : (new : unit -> 'MonadClass)> 
107:         (m : Generic<'T, 'MonadClass>) (f : 'T -> Generic<'R, 'MonadClass>) : Generic<'R, 'MonadClass> = 
108:         (new 'MonadClass()).Bind(m, f)
109: 
110:     let (>>=) = bind
111:     let (>>) ma mb = ma >>= fun _ -> mb
112: 
113:     let rec sequence (list : Generic<'T, 'MonadClass> list) : Generic<'T list, 'MonadClass> = 
114:             match list with
115:             | [] -> unit []
116:             | m :: ms -> m >>= fun v -> sequence ms >>= fun vs -> unit (v :: vs)
117: 
118:     let mapM (f : 'T -> Generic<'R, 'MonadClass>) (list : 'T list) : Generic<'R list, 'MonadClass> = 
119:         (sequence << List.map f) list
120: 
121:     let rec filterM (p : 'T -> Generic<bool, 'MonadClass>) (list : 'T list) : Generic<'T list, 'MonadClass> =
122:         match list  with
123:         | [] -> unit []
124:         | x :: xs -> p x >>= fun b -> filterM p xs >>= fun ys -> if b then unit (x :: ys) else unit ys
125: 
126: // Examples
127: 
128: // Maybe Monad Examples
129: maybe { return 1 } >>= fun k -> maybe { return k + 1 } // Some 2
130: maybe { let! k = maybe { return 1 } in return k + 1 } // Some 2
131: 
132: sequence [maybe { return 1 }; maybe { return 2 }; maybe { return 3 }] // Some [1; 2; 3]
133: mapM (fun v -> maybe { return v * 2 }) [1 .. 5] //  Some [2; 4; 6; 8]
134: filterM (fun v -> maybe { return v % 2 = 0 }) [1..5] // Some [2; 4]
135: 
136: // ZipList example
137: let rec transpose (listoflist : LazyList<LazyList<'T>>) : Generic<LazyList<'T>, ListApplicativeClass> = 
138:     match listoflist with
139:     | LazyList.Nil -> pure LazyList.empty
140:     | LazyList.Cons (xs, xss) -> LazyList.cons $ (ListAppGeneric xs) <*> transpose xss
141: 
142: [[1; 2; 3]; [4; 5; 6]]
143:   |> LazyList.ofList
144:   |> LazyList.map LazyList.ofList
145:   |> transpose // result: ListAppGeneric (seq [seq [1; 4]; seq [2; 5]; seq [3; 6]])
146: 
147: // List Monad example
148: let onetoten = ListMonadGeneric (LazyList.ofList [1..3]) 
149: (fun a b -> sprintf "%d * %d = %d" a b (a * b)) $ onetoten <*> onetoten 
150: // result: ListMonadGeneric (seq ["1 * 1 = 1"; "1 * 2 = 2"; "1 * 3 = 3"; "2 * 1 = 2"; ...])
namespace System
Multiple items
type Generic<'T,'TypeClass (requires default constructor)> =
  interface
  end

Full name: Snippet.Generic<_,_>

--------------------

Generic
type unit = Unit

Full name: Microsoft.FSharp.Core.unit

  type: unit
  implements: IComparable
type AbstractClassAttribute =
  class
    inherit Attribute
    new : unit -> AbstractClassAttribute
  end

Full name: Microsoft.FSharp.Core.AbstractClassAttribute

  type: AbstractClassAttribute
  implements: Runtime.InteropServices._Attribute
  inherits: Attribute
type FunctorClass<'FunctorClass (requires 'FunctorClass :> FunctorClass<'FunctorClass> and default constructor)> =
  class
    new : unit -> FunctorClass<'FunctorClass>
    abstract member FMap : ('T -> 'R) -> Generic<'T,'FunctorClass> -> Generic<'R,'FunctorClass>
  end

Full name: Snippet.FunctorClass<_>
abstract member FunctorClass.FMap : ('T -> 'R) -> Generic<'T,'FunctorClass> -> Generic<'R,'FunctorClass>

Full name: Snippet.FunctorClass`1.FMap
type ApplicativeClass<'ApplicativeClass (requires 'ApplicativeClass :> ApplicativeClass<'ApplicativeClass> and default constructor)> =
  class
    inherit FunctorClass<'ApplicativeClass>
    new : unit -> ApplicativeClass<'ApplicativeClass>
    abstract member Apply : Generic<('T -> 'R),'ApplicativeClass> -> Generic<'T,'ApplicativeClass> -> Generic<'R,'ApplicativeClass>
    abstract member Pure : 'T -> Generic<'T,'ApplicativeClass>
    override FMap : f:('T -> 'R) -> fa:Generic<'T,'ApplicativeClass> -> Generic<'R,'ApplicativeClass>
  end

Full name: Snippet.ApplicativeClass<_>

  type: ApplicativeClass<'ApplicativeClass>
  inherits: FunctorClass<'ApplicativeClass>
abstract member ApplicativeClass.Pure : 'T -> Generic<'T,'ApplicativeClass>

Full name: Snippet.ApplicativeClass`1.Pure
abstract member ApplicativeClass.Apply : Generic<('T -> 'R),'ApplicativeClass> -> Generic<'T,'ApplicativeClass> -> Generic<'R,'ApplicativeClass>

Full name: Snippet.ApplicativeClass`1.Apply
val this : ApplicativeClass<'ApplicativeClass> (requires 'ApplicativeClass :> ApplicativeClass<'ApplicativeClass> and default constructor)

  type: ApplicativeClass<'ApplicativeClass>
  inherits: FunctorClass<'ApplicativeClass>
override ApplicativeClass.FMap : f:('T -> 'R) -> fa:Generic<'T,'ApplicativeClass> -> Generic<'R,'ApplicativeClass>

Full name: Snippet.ApplicativeClass`1.FMap
val f : ('T -> 'R)
val fa : Generic<'T,'ApplicativeClass> (requires 'ApplicativeClass :> ApplicativeClass<'ApplicativeClass> and default constructor)
abstract member ApplicativeClass.Apply : Generic<('T -> 'R),'ApplicativeClass> -> Generic<'T,'ApplicativeClass> -> Generic<'R,'ApplicativeClass>
abstract member ApplicativeClass.Pure : 'T -> Generic<'T,'ApplicativeClass>
type MonadClass<'MonadClass (requires 'MonadClass :> MonadClass<'MonadClass> and default constructor)> =
  class
    inherit ApplicativeClass<'MonadClass>
    new : unit -> MonadClass<'MonadClass>
    abstract member Bind : Generic<'T,'MonadClass> * ('T -> Generic<'R,'MonadClass>) -> Generic<'R,'MonadClass>
    abstract member Return : 'T -> Generic<'T,'MonadClass>
    override Apply : mf:Generic<('T -> 'R),'MonadClass> -> ma:Generic<'T,'MonadClass> -> Generic<'R,'MonadClass>
    override Pure : value:'T -> Generic<'T,'MonadClass>
    member Then : ma:Generic<'T,'MonadClass> * mb:Generic<'R,'MonadClass> -> Generic<'R,'MonadClass>
  end

Full name: Snippet.MonadClass<_>

  type: MonadClass<'MonadClass>
  inherits: ApplicativeClass<'MonadClass>
  inherits: FunctorClass<'MonadClass>
abstract member MonadClass.Return : 'T -> Generic<'T,'MonadClass>

Full name: Snippet.MonadClass`1.Return
abstract member MonadClass.Bind : Generic<'T,'MonadClass> * ('T -> Generic<'R,'MonadClass>) -> Generic<'R,'MonadClass>

Full name: Snippet.MonadClass`1.Bind
val this : MonadClass<'MonadClass> (requires 'MonadClass :> MonadClass<'MonadClass> and default constructor)

  type: MonadClass<'MonadClass>
  inherits: ApplicativeClass<'MonadClass>
  inherits: FunctorClass<'MonadClass>
member MonadClass.Then : ma:Generic<'T,'MonadClass> * mb:Generic<'R,'MonadClass> -> Generic<'R,'MonadClass>

Full name: Snippet.MonadClass`1.Then
val ma : Generic<'T,'MonadClass> (requires 'MonadClass :> MonadClass<'MonadClass> and default constructor)
val mb : Generic<'R,'MonadClass> (requires 'MonadClass :> MonadClass<'MonadClass> and default constructor)
abstract member MonadClass.Bind : Generic<'T,'MonadClass> * ('T -> Generic<'R,'MonadClass>) -> Generic<'R,'MonadClass>
override MonadClass.Pure : value:'T -> Generic<'T,'MonadClass>

Full name: Snippet.MonadClass`1.Pure
val value : 'T
abstract member MonadClass.Return : 'T -> Generic<'T,'MonadClass>
override MonadClass.Apply : mf:Generic<('T -> 'R),'MonadClass> -> ma:Generic<'T,'MonadClass> -> Generic<'R,'MonadClass>

Full name: Snippet.MonadClass`1.Apply
val mf : Generic<('T -> 'R),'MonadClass> (requires 'MonadClass :> MonadClass<'MonadClass> and default constructor)
val a : 'T
type Maybe<'T> =
  | None
  | Some of 'T
  with
    interface Generic<'T,MaybeClass>
  end

Full name: Snippet.Maybe<_>

  type: Maybe<'T>
  implements: IEquatable<Maybe<'T>>
  implements: Collections.IStructuralEquatable
  implements: IComparable<Maybe<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Generic<'T,MaybeClass>
union case Maybe.None: Maybe<'T>
union case Maybe.Some: 'T -> Maybe<'T>
type MaybeClass =
  class
    inherit MonadClass<MaybeClass>
    new : unit -> MaybeClass
    override Bind : m:Generic<'T,MaybeClass> * f:('T -> Generic<'R,MaybeClass>) -> Generic<'R,MaybeClass>
    override Return : v:'T -> Generic<'T,MaybeClass>
  end

Full name: Snippet.MaybeClass

  type: MaybeClass
  inherits: MonadClass<MaybeClass>
  inherits: ApplicativeClass<MaybeClass>
  inherits: FunctorClass<MaybeClass>
val this : MaybeClass

  type: MaybeClass
  inherits: MonadClass<MaybeClass>
  inherits: ApplicativeClass<MaybeClass>
  inherits: FunctorClass<MaybeClass>
override MaybeClass.Return : v:'T -> Generic<'T,MaybeClass>

Full name: Snippet.MaybeClass.Return
val v : 'T
override MaybeClass.Bind : m:Generic<'T,MaybeClass> * f:('T -> Generic<'R,MaybeClass>) -> Generic<'R,MaybeClass>

Full name: Snippet.MaybeClass.Bind
val m : Generic<'T,MaybeClass>
val f : ('T -> Generic<'R,MaybeClass>)
val maybe : MonadClass<MaybeClass>

Full name: Snippet.maybe

  type: MonadClass<MaybeClass>
  inherits: ApplicativeClass<MaybeClass>
  inherits: FunctorClass<MaybeClass>
Multiple items
union case ListMonadGeneric.ListMonadGeneric: LazyList<'T> -> ListMonadGeneric<'T>

--------------------

type ListMonadGeneric<'T> =
  | ListMonadGeneric of LazyList<'T>
  with
    interface Generic<'T,ListMonadClass>
  end

Full name: Snippet.ListMonadGeneric<_>

  type: ListMonadGeneric<'T>
  implements: IEquatable<ListMonadGeneric<'T>>
  implements: Collections.IStructuralEquatable
  implements: Generic<'T,ListMonadClass>
Multiple items
module LazyList

from Microsoft.FSharp.Collections

--------------------

type LazyList<'T>
with
  interface Collections.IEnumerable
  interface Collections.Generic.IEnumerable<'T>
end

Full name: Microsoft.FSharp.Collections.LazyList<_>

  type: LazyList<'T>
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
type ListMonadClass =
  class
    inherit MonadClass<ListMonadClass>
    new : unit -> ListMonadClass
    override Bind : m:Generic<'T,ListMonadClass> * f:('T -> Generic<'R,ListMonadClass>) -> Generic<'R,ListMonadClass>
    override Return : v:'T -> Generic<'T,ListMonadClass>
  end

Full name: Snippet.ListMonadClass

  type: ListMonadClass
  inherits: MonadClass<ListMonadClass>
  inherits: ApplicativeClass<ListMonadClass>
  inherits: FunctorClass<ListMonadClass>
val this : ListMonadClass

  type: ListMonadClass
  inherits: MonadClass<ListMonadClass>
  inherits: ApplicativeClass<ListMonadClass>
  inherits: FunctorClass<ListMonadClass>
override ListMonadClass.Return : v:'T -> Generic<'T,ListMonadClass>

Full name: Snippet.ListMonadClass.Return
val ofList : 'T list -> LazyList<'T>

Full name: Microsoft.FSharp.Collections.LazyList.ofList
override ListMonadClass.Bind : m:Generic<'T,ListMonadClass> * f:('T -> Generic<'R,ListMonadClass>) -> Generic<'R,ListMonadClass>

Full name: Snippet.ListMonadClass.Bind
val m : Generic<'T,ListMonadClass>
val f : ('T -> Generic<'R,ListMonadClass>)
Multiple items
val list : LazyList<'T>

  type: LazyList<'T>
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable


--------------------

type 'T list = List<'T>

Full name: Microsoft.FSharp.Collections.list<_>

  type: 'T list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
val ofSeq : seq<'T> -> LazyList<'T>

Full name: Microsoft.FSharp.Collections.LazyList.ofSeq
module Seq

from Microsoft.FSharp.Collections
val collect : ('T -> #seq<'U>) -> seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.collect
val list' : LazyList<'R>

  type: LazyList<'R>
  implements: Collections.Generic.IEnumerable<'R>
  implements: Collections.IEnumerable
Multiple items
union case ListAppGeneric.ListAppGeneric: LazyList<'T> -> ListAppGeneric<'T>

--------------------

type ListAppGeneric<'T> =
  | ListAppGeneric of LazyList<'T>
  with
    interface Generic<'T,ListApplicativeClass>
  end

Full name: Snippet.ListAppGeneric<_>

  type: ListAppGeneric<'T>
  implements: IEquatable<ListAppGeneric<'T>>
  implements: Collections.IStructuralEquatable
  implements: Generic<'T,ListApplicativeClass>
type ListApplicativeClass =
  class
    inherit ApplicativeClass<ListApplicativeClass>
    new : unit -> ListApplicativeClass
    override Apply : ff:Generic<('T -> 'R),ListApplicativeClass> -> fa:Generic<'T,ListApplicativeClass> -> Generic<'R,ListApplicativeClass>
    override Pure : v:'T -> Generic<'T,ListApplicativeClass>
  end

Full name: Snippet.ListApplicativeClass

  type: ListApplicativeClass
  inherits: ApplicativeClass<ListApplicativeClass>
  inherits: FunctorClass<ListApplicativeClass>
val this : ListApplicativeClass

  type: ListApplicativeClass
  inherits: ApplicativeClass<ListApplicativeClass>
  inherits: FunctorClass<ListApplicativeClass>
override ListApplicativeClass.Pure : v:'T -> Generic<'T,ListApplicativeClass>

Full name: Snippet.ListApplicativeClass.Pure
val repeat : 'T -> LazyList<'T>

Full name: Microsoft.FSharp.Collections.LazyList.repeat
override ListApplicativeClass.Apply : ff:Generic<('T -> 'R),ListApplicativeClass> -> fa:Generic<'T,ListApplicativeClass> -> Generic<'R,ListApplicativeClass>

Full name: Snippet.ListApplicativeClass.Apply
val ff : Generic<('T -> 'R),ListApplicativeClass>
val fa : Generic<'T,ListApplicativeClass>
val listf : LazyList<('T -> 'R)>

  type: LazyList<('T -> 'R)>
  implements: Collections.Generic.IEnumerable<('T -> 'R)>
  implements: Collections.IEnumerable
val map : ('T -> 'U) -> LazyList<'T> -> LazyList<'U>

Full name: Microsoft.FSharp.Collections.LazyList.map
val zip : LazyList<'T1> -> LazyList<'T2> -> LazyList<'T1 * 'T2>

Full name: Microsoft.FSharp.Collections.LazyList.zip
type AutoOpenAttribute =
  class
    inherit Attribute
    new : unit -> AutoOpenAttribute
    new : path:string -> AutoOpenAttribute
    member Path : string
  end

Full name: Microsoft.FSharp.Core.AutoOpenAttribute

  type: AutoOpenAttribute
  implements: Runtime.InteropServices._Attribute
  inherits: Attribute
val pure : 'T -> Generic<'T,'ApplicativeClass> (requires 'ApplicativeClass :> ApplicativeClass<'ApplicativeClass> and default constructor)

Full name: Snippet.ApplicativeModule.pure
val apply : Generic<('T -> 'R),'ApplicativeClass> -> Generic<'T,'ApplicativeClass> -> Generic<'R,'ApplicativeClass> (requires 'ApplicativeClass :> ApplicativeClass<'ApplicativeClass> and default constructor)

Full name: Snippet.ApplicativeModule.apply
val ff : Generic<('T -> 'R),'ApplicativeClass> (requires 'ApplicativeClass :> ApplicativeClass<'ApplicativeClass> and default constructor)
val ff : Generic<('a -> 'b),'c> (requires 'c :> ApplicativeClass<'c> and default constructor)
val fa : Generic<'a,'c> (requires 'c :> ApplicativeClass<'c> and default constructor)
val f : ('a -> 'b)
val fa : Generic<'a,'b> (requires 'b :> ApplicativeClass<'b> and default constructor)
val fb : Generic<'c,'b> (requires 'b :> ApplicativeClass<'b> and default constructor)
val a : 'a
val b : 'c
Multiple items
val unit : 'T -> Generic<'T,'MonadClass> (requires 'MonadClass :> MonadClass<'MonadClass> and default constructor)

Full name: Snippet.MonadModule.unit

--------------------

type unit = Unit

Full name: Microsoft.FSharp.Core.unit

  type: unit
  implements: IComparable
val bind : Generic<'T,'MonadClass> -> ('T -> Generic<'R,'MonadClass>) -> Generic<'R,'MonadClass> (requires 'MonadClass :> MonadClass<'MonadClass> and default constructor)

Full name: Snippet.MonadModule.bind
val m : Generic<'T,'MonadClass> (requires 'MonadClass :> MonadClass<'MonadClass> and default constructor)
val f : ('T -> Generic<'R,'MonadClass>) (requires 'MonadClass :> MonadClass<'MonadClass> and default constructor)
val ma : Generic<'a,'b> (requires 'b :> MonadClass<'b> and default constructor)
val mb : Generic<'c,'b> (requires 'b :> MonadClass<'b> and default constructor)
val sequence : Generic<'T,'MonadClass> list -> Generic<'T list,'MonadClass> (requires default constructor and 'MonadClass :> MonadClass<'MonadClass>)

Full name: Snippet.MonadModule.sequence
Multiple items
val list : Generic<'T,'MonadClass> list (requires default constructor and 'MonadClass :> MonadClass<'MonadClass>)

  type: Generic<'T,'MonadClass> list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<Generic<'T,'MonadClass>>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<Generic<'T,'MonadClass>>
  implements: Collections.IEnumerable


--------------------

type 'T list = List<'T>

Full name: Microsoft.FSharp.Collections.list<_>

  type: 'T list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
val m : Generic<'T,'MonadClass> (requires default constructor and 'MonadClass :> MonadClass<'MonadClass>)
val ms : Generic<'T,'MonadClass> list (requires default constructor and 'MonadClass :> MonadClass<'MonadClass>)

  type: Generic<'T,'MonadClass> list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<Generic<'T,'MonadClass>>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<Generic<'T,'MonadClass>>
  implements: Collections.IEnumerable
val vs : 'T list

  type: 'T list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
val mapM : ('T -> Generic<'R,'MonadClass>) -> 'T list -> Generic<'R list,'MonadClass> (requires default constructor and 'MonadClass :> MonadClass<'MonadClass>)

Full name: Snippet.MonadModule.mapM
val f : ('T -> Generic<'R,'MonadClass>) (requires default constructor and 'MonadClass :> MonadClass<'MonadClass>)
Multiple items
val list : 'T list

  type: 'T list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable


--------------------

type 'T list = List<'T>

Full name: Microsoft.FSharp.Collections.list<_>

  type: 'T list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------

type List<'T> =
  | ( [] )
  | ( :: ) of 'T * 'T list
  with
    interface Collections.IEnumerable
    interface Collections.Generic.IEnumerable<'T>
    member Head : 'T
    member IsEmpty : bool
    member Item : index:int -> 'T with get
    member Length : int
    member Tail : 'T list
    static member Cons : head:'T * tail:'T list -> 'T list
    static member Empty : 'T list
  end

Full name: Microsoft.FSharp.Collections.List<_>

  type: List<'T>
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
val map : ('T -> 'U) -> 'T list -> 'U list

Full name: Microsoft.FSharp.Collections.List.map
val filterM : ('T -> Generic<bool,'MonadClass>) -> 'T list -> Generic<'T list,'MonadClass> (requires default constructor and 'MonadClass :> MonadClass<'MonadClass>)

Full name: Snippet.MonadModule.filterM
val p : ('T -> Generic<bool,'MonadClass>) (requires default constructor and 'MonadClass :> MonadClass<'MonadClass>)
type bool = Boolean

Full name: Microsoft.FSharp.Core.bool

  type: bool
  implements: IComparable
  implements: IConvertible
  implements: IComparable<bool>
  implements: IEquatable<bool>
  inherits: ValueType
val x : 'T
val xs : 'T list

  type: 'T list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
val b : bool

  type: bool
  implements: IComparable
  implements: IConvertible
  implements: IComparable<bool>
  implements: IEquatable<bool>
  inherits: ValueType
val ys : 'T list

  type: 'T list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
val k : int

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val v : int

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val transpose : LazyList<LazyList<'T>> -> Generic<LazyList<'T>,ListApplicativeClass>

Full name: Snippet.transpose
val listoflist : LazyList<LazyList<'T>>

  type: LazyList<LazyList<'T>>
  implements: Collections.Generic.IEnumerable<LazyList<'T>>
  implements: Collections.IEnumerable
active recognizer Nil: LazyList<'T> -> Choice<('T * LazyList<'T>),unit>

Full name: Microsoft.FSharp.Collections.LazyList.( |Cons|Nil| )
val empty<'T> : LazyList<'T>

Full name: Microsoft.FSharp.Collections.LazyList.empty
active recognizer Cons: LazyList<'T> -> Choice<('T * LazyList<'T>),unit>

Full name: Microsoft.FSharp.Collections.LazyList.( |Cons|Nil| )
val xs : LazyList<'T>

  type: LazyList<'T>
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
val xss : LazyList<LazyList<'T>>

  type: LazyList<LazyList<'T>>
  implements: Collections.Generic.IEnumerable<LazyList<'T>>
  implements: Collections.IEnumerable
val cons : 'T -> LazyList<'T> -> LazyList<'T>

Full name: Microsoft.FSharp.Collections.LazyList.cons
val onetoten : ListMonadGeneric<int>

Full name: Snippet.onetoten

  type: ListMonadGeneric<int>
  implements: IEquatable<ListMonadGeneric<int>>
  implements: Collections.IStructuralEquatable
  implements: Generic<int,ListMonadClass>
val a : int

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val b : int

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val sprintf : Printf.StringFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf

More information

Link: http://fssnip.net/3S
Posted: 3 years ago
Author: Nick Palladinos
Tags: Functors, Applicative Functors, Monads