moving on to the next revision and refinement. revisiting ideas.
This commit is contained in:
parent
825980ca31
commit
75ee8f04e5
1 changed files with 75 additions and 0 deletions
75
docs/revision3.md
Normal file
75
docs/revision3.md
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
```
|
||||
given A
|
||||
def identity: A -> A
|
||||
λ x => x
|
||||
end def
|
||||
|
||||
given A
|
||||
class Semigroup A
|
||||
def combine: A -> A -> A
|
||||
end class
|
||||
|
||||
given A :: Semigroup
|
||||
class Monoid A
|
||||
def empty: A
|
||||
end class
|
||||
|
||||
given F *
|
||||
class Functor
|
||||
given A
|
||||
given B
|
||||
def map: F A -> (A -> B) -> F B
|
||||
end class
|
||||
|
||||
given F * :: Functor
|
||||
class Apply
|
||||
given A
|
||||
given B
|
||||
def ap: F (A -> B) -> F A -> F B
|
||||
end class
|
||||
|
||||
given F * :: Apply
|
||||
class Applicative
|
||||
given A
|
||||
def pure: A -> F A
|
||||
|
||||
def unit: F ()
|
||||
pure ()
|
||||
end def
|
||||
end class
|
||||
|
||||
given F * :: Apply
|
||||
class FlatMap
|
||||
given A
|
||||
given B
|
||||
def fmap: F A -> (A -> F B) -> F B
|
||||
|
||||
given A
|
||||
def flatten: F (F A) -> F A
|
||||
λ ffa => fmap ffa identity
|
||||
end def
|
||||
end class
|
||||
|
||||
given F * :: FlatMap, Applicative
|
||||
class Monad
|
||||
end class
|
||||
|
||||
instance Semigroup Int32
|
||||
def combine: Int32 -> Int32 -> Int32
|
||||
int32_add
|
||||
end def
|
||||
end instance
|
||||
|
||||
given A :: Semigroup
|
||||
def +: A -> A -> A
|
||||
combine
|
||||
end def
|
||||
|
||||
def ex1: Int32 -> Int32
|
||||
λ x => x + x
|
||||
end def
|
||||
|
||||
def ex2: Int32 -> Int32
|
||||
λ x => combine x x
|
||||
end def
|
||||
```
|
||||
Loading…
Add table
Reference in a new issue