feat: solvers and ball example
This commit is contained in:
parent
cc099c02e7
commit
e07f165494
27 changed files with 1483 additions and 290 deletions
|
|
@ -1,26 +0,0 @@
|
|||
|
||||
module type Monad = sig
|
||||
type 'a t
|
||||
|
||||
val return : 'a -> 'a t
|
||||
val bind : 'a t -> ('a -> 'b t) -> 'b t
|
||||
end
|
||||
|
||||
module type FullMonad = sig
|
||||
type 'a t
|
||||
|
||||
val return : 'a -> 'a t
|
||||
val bind : 'a t -> ('a -> 'b t) -> 'b t
|
||||
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
|
||||
val (let*) : 'a t -> ('a -> 'b t) -> 'b t
|
||||
val join : 'a t t -> 'a t
|
||||
end
|
||||
|
||||
module Expand (M : Monad) = struct
|
||||
include M
|
||||
|
||||
let (>>=) = M.bind
|
||||
let (let*) = M.bind
|
||||
let join m = M.bind m (fun m -> m)
|
||||
end
|
||||
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
module type Monad = sig
|
||||
type 'a t
|
||||
|
||||
val return : 'a -> 'a t
|
||||
val bind : 'a t -> ('a -> 'b t) -> 'b t
|
||||
end
|
||||
|
||||
module type FullMonad = sig
|
||||
type 'a t
|
||||
|
||||
val return : 'a -> 'a t
|
||||
val bind : 'a t -> ('a -> 'b t) -> 'b t
|
||||
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
|
||||
val (let*) : 'a t -> ('a -> 'b t) -> 'b t
|
||||
val join : 'a t t -> 'a t
|
||||
end
|
||||
|
||||
module Expand : functor (M : Monad) -> FullMonad with type 'a t = 'a M.t
|
||||
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
open Utils
|
||||
|
||||
module Make (S : sig
|
||||
type t
|
||||
end) =
|
||||
struct
|
||||
|
||||
module State = struct
|
||||
type 'a t = S.t -> 'a * S.t
|
||||
|
||||
let return = pair
|
||||
let bind m f = uncurry f @. m
|
||||
end
|
||||
|
||||
module M = Monad.Expand (State)
|
||||
include M
|
||||
|
||||
let get () s = s, s
|
||||
let set x _ = (), x
|
||||
let run m = fst @. m
|
||||
end
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
|
||||
module Make (S : sig
|
||||
type t
|
||||
end) : sig
|
||||
type 'a t
|
||||
|
||||
val return : 'a -> 'a t
|
||||
val bind : 'a t -> ('a -> 'b t) -> 'b t
|
||||
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
|
||||
val (let*) : 'a t -> ('a -> 'b t) -> 'b t
|
||||
|
||||
val get : unit -> S.t t
|
||||
val set : S.t -> unit t
|
||||
|
||||
val run : 'a t -> S.t -> 'a
|
||||
end
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue