Using defn for definitions (type classes)
This commit is contained in:
parent
6a08ad31f0
commit
4962291f89
1 changed files with 17 additions and 17 deletions
|
@ -3,12 +3,12 @@
|
||||||
```
|
```
|
||||||
given A
|
given A
|
||||||
class Semigroup
|
class Semigroup
|
||||||
fn combine: A -> A -> A
|
defn combine: A -> A -> A
|
||||||
end class
|
end class
|
||||||
|
|
||||||
given A :: Semigroup
|
given A :: Semigroup
|
||||||
class Monoid
|
class Monoid
|
||||||
fn empty: A
|
defn empty: A
|
||||||
end class
|
end class
|
||||||
|
|
||||||
--- Type class for type constructors which can be mapped over.
|
--- Type class for type constructors which can be mapped over.
|
||||||
|
@ -27,22 +27,22 @@ class Functor
|
||||||
--- @param fa The functor input.
|
--- @param fa The functor input.
|
||||||
--- @param f The function to transform data from `A` to `B`.
|
--- @param f The function to transform data from `A` to `B`.
|
||||||
given A, B
|
given A, B
|
||||||
fn map: F A -> (A -> B) -> F B
|
defn map: F A -> (A -> B) -> F B
|
||||||
end class
|
end class
|
||||||
|
|
||||||
given F * :: Functor
|
given F * :: Functor
|
||||||
class Apply
|
class Apply
|
||||||
given A, B
|
given A, B
|
||||||
fn ap: F (A -> B) -> F A -> F B
|
defn ap: F (A -> B) -> F A -> F B
|
||||||
end class
|
end class
|
||||||
|
|
||||||
given F * :: Apply
|
given F * :: Apply
|
||||||
class Applicative
|
class Applicative
|
||||||
given A
|
given A
|
||||||
fn pure: A -> F A
|
defn pure: A -> F A
|
||||||
|
|
||||||
fn unit: F ()
|
fn unit: F
|
||||||
pure ()
|
λ => pure ()
|
||||||
end fn
|
end fn
|
||||||
end class
|
end class
|
||||||
|
|
||||||
|
@ -51,18 +51,18 @@ given F * :: Applicative
|
||||||
instance Functor F
|
instance Functor F
|
||||||
given A, B
|
given A, B
|
||||||
fn map: F A -> (A -> B) -> F B
|
fn map: F A -> (A -> B) -> F B
|
||||||
fa f => ap (pure f) fa
|
λ fa f => ap (pure f) fa
|
||||||
end fn
|
end fn
|
||||||
end instance
|
end instance
|
||||||
|
|
||||||
given F * :: Apply
|
given F * :: Apply
|
||||||
class FlatMap
|
class FlatMap
|
||||||
given A, B
|
given A, B
|
||||||
fn fmap: F A -> (A -> F B) -> F B
|
defn fmap: F A -> (A -> F B) -> F B
|
||||||
|
|
||||||
given A
|
given A
|
||||||
fn flatten: F (F A) -> F A
|
fn flatten: F (F A) -> F A
|
||||||
ffa => fmap ffa (fa => fa)
|
λ ffa => fmap ffa (fa => fa)
|
||||||
end fn
|
end fn
|
||||||
end class
|
end class
|
||||||
|
|
||||||
|
@ -80,13 +80,13 @@ end instance
|
||||||
given F * *
|
given F * *
|
||||||
class Bifunctor
|
class Bifunctor
|
||||||
given A, B, C, D
|
given A, B, C, D
|
||||||
fn bimap F A B -> (A -> C) -> (B -> D) -> F C D
|
defn bimap F A B -> (A -> C) -> (B -> D) -> F C D
|
||||||
end class
|
end class
|
||||||
|
|
||||||
given F * :: Functor
|
given F * :: Functor
|
||||||
class CoFlatMap
|
class CoFlatMap
|
||||||
given A, B
|
given A, B
|
||||||
fn cofmap: F A -> (F A -> B) -> F B
|
defn cofmap: F A -> (F A -> B) -> F B
|
||||||
|
|
||||||
given A
|
given A
|
||||||
fn coflatten: F A -> F (F A)
|
fn coflatten: F A -> F (F A)
|
||||||
|
@ -97,17 +97,17 @@ end class
|
||||||
given F * :: CoFlatMap
|
given F * :: CoFlatMap
|
||||||
class CoMonad
|
class CoMonad
|
||||||
given A
|
given A
|
||||||
fn extract: F A -> A
|
defn extract: F A -> A
|
||||||
end class
|
end class
|
||||||
|
|
||||||
given A
|
given A
|
||||||
class Show
|
class Show
|
||||||
fn show: A -> String
|
defn show: A -> String
|
||||||
end class
|
end class
|
||||||
|
|
||||||
given A, B
|
given A, B
|
||||||
class Eq
|
class Eq
|
||||||
fn eq: A -> B -> Boolean
|
defn eq: A -> B -> Boolean
|
||||||
|
|
||||||
fn neq: A -> B -> Boolean
|
fn neq: A -> B -> Boolean
|
||||||
λ x y => not (eq x y)
|
λ x y => not (eq x y)
|
||||||
|
@ -130,7 +130,7 @@ end enum
|
||||||
|
|
||||||
given A
|
given A
|
||||||
class Compare
|
class Compare
|
||||||
fn compare: A -> A -> Comparison
|
defn compare: A -> A -> Comparison
|
||||||
end class
|
end class
|
||||||
|
|
||||||
given A :: Compare
|
given A :: Compare
|
||||||
|
@ -146,6 +146,6 @@ end instance
|
||||||
|
|
||||||
given A
|
given A
|
||||||
class HashCode
|
class HashCode
|
||||||
fn hash_code: A -> Int32
|
defn hash_code: A -> Int32
|
||||||
end class
|
end class
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue