Last active
May 15, 2021 10:46
-
-
Save shamansir/64e46a208f5f6c325b67c56c5e06f769 to your computer and use it in GitHub Desktop.
PureScript typeclasses in CUE -> JSON, for https://imgur.com/a/ESOR7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plus: { | |
name: "Plus" | |
info: "Left and Right identity for Alt" | |
parent: "alt" | |
"package": "Control*" | |
members: | |
[ | |
{ name: "empty" | |
, def: "f a" | |
, laws : // FIXME: laws are incorrect | |
[ | |
{ law: "associativity" | |
, example: | |
{ left: "(x <|> y) <|> z" | |
, right: "x <|> (y <|> z)" | |
} | |
} | |
, | |
{ law: "distributivity" | |
, example: | |
{ left: "f <$> (x <|> y)" | |
, right: "(f <$> x) <|> (f <$> y)" | |
} | |
} | |
] | |
} | |
, | |
] | |
instances: [ "Array", ] | |
} | |
comonad: { | |
name: "Comonad" | |
info: "Left and Right identity for Alt" | |
parent: "extend" | |
"package": "Control*" | |
members: | |
[ | |
{ name: "extract" | |
, def: "w a -> a" | |
, laws : | |
[ | |
{ law: "left identity" | |
, example: | |
{ left: "extract <<== xs" | |
, right: "xs" | |
} | |
} | |
, | |
{ law: "right identity" | |
, example: | |
{ left: "extract (f <<== xs)" | |
, right: "f xs" | |
} | |
} | |
] | |
} | |
, | |
] | |
instances: [ ] | |
} | |
semigroupoid: { | |
name: "Semigroupoid" | |
info: "Category without identity" | |
"package": "Control" | |
members: | |
[ | |
{ name: "compose" | |
, def: "a c d -> a b c -> a b d" | |
, op: "<<<" | |
, opEmoji: "🔙" | |
, laws : | |
[ | |
{ law: "associativity" | |
, example: | |
{ left: "p <<< (q <<< r)" | |
, right: "(p <<< q) <<< r" | |
} | |
} | |
] | |
} | |
, | |
{ name: "composeFlipped" | |
, def: "Semigroupoid a => a b c -> a c d -> a b d" | |
, op: ">>>" | |
, opEmoji: "🔜" | |
} | |
] | |
instances: [ ] | |
} | |
category: { | |
name: "Category" | |
info: "Objects and composable morphisms with their identity" | |
parent: "semigroupoid" | |
"package": "Control" | |
members: | |
[ | |
{ name: "id" | |
, def: "a t t" | |
, laws : | |
[ | |
{ law: "identity" | |
, example: | |
{ left: "id <<< p" | |
, middle: "p <<< id" | |
, right: "p" | |
} | |
} | |
] | |
} | |
] | |
instances: [ "(->)" ] | |
} | |
lazy: { | |
name: "Lazy" | |
info: "Deferred operations" | |
"package": "Control*" | |
members: | |
[ | |
{ name: "defer" | |
, def: "(Unit -> l) -> l" | |
} | |
, { name: "fix" | |
, def: "Lazy l => (l -> l) -> l" | |
} | |
] | |
instances: [ "(a -> b)", "Unit" ] | |
} | |
alt: { | |
name: "Alt" | |
info: "Associative operation on a constructor" | |
parent: "functor" | |
"package": "Control*" | |
members: | |
[ | |
{ name: "alt" | |
, def: "f a -> f a -> f a" | |
, op: "<|>" | |
, opEmoji: "🔗" | |
, laws : | |
[ | |
{ law: "associativity" | |
, example: | |
{ left: "(x <|> y) <|> z" | |
, right: "x <|> (y <|> z)" | |
} | |
} | |
, | |
{ law: "distributivity" | |
, example: | |
{ left: "f <$> (x <|> y)" | |
, right: "(f <$> x) <|> (f <$> y)" | |
} | |
} | |
] | |
} | |
, | |
] | |
instances: [ "Array", ] | |
} | |
extend : { | |
name: "Extend" | |
info: "Extend local computation to a global one" | |
parent: "functor" | |
"package": "Control*" | |
members: | |
[ | |
{ name: "extend" | |
, def: "m a -> (a -> m b) -> m b" | |
, op: "<<==" | |
, laws : | |
[ | |
{ law: "associativity" | |
, example: | |
{ left: "extend f <<< extend g" | |
, right: "extend (f <<< extend g)" | |
} | |
} | |
] | |
} | |
, | |
{ name: "extendFlipped" | |
, def: "Extend w => w a -> (w a -> b) -> w b" | |
, op: "==>>" | |
} | |
, | |
{ name: "composeCoKleisli" | |
, def: "Extend w => (w a -> b) -> (w b -> c) -> w a -> c" | |
, op: "=>=" | |
} | |
, | |
{ name: "composeCoKleisliFlipped" | |
, def: "Extend w => (w b -> c) -> (w a -> b) -> w a -> c" | |
, op: "=<=" | |
} | |
, | |
{ name: "duplicate" | |
, def: "Extend w => w a -> w (w a)" | |
} | |
] | |
instances: [ "Semigroup w => Extend ((->) w)", "Array", ] | |
} | |
bind : { | |
name: "Bind" | |
info: "Compose computations" | |
parent: "apply" | |
members: | |
[ | |
{ name: "bind" | |
, def: "m a -> (a -> m b) -> m b" | |
, op: ">>=" | |
, opEmoji: "🎉" | |
, laws : | |
[ | |
{ law: "associativity" | |
, example: | |
{ left: "(x >>= f) >>= g" | |
, right: "x >>= (\\k -> f k >>= g)" | |
} | |
} | |
] | |
} | |
, | |
{ name: "bindFlipped" | |
, def: "Bind m => (a -> m b) -> m a -> m b" | |
, op: "==<<" | |
} | |
, | |
{ name: "join" | |
, def: "Bind m => m (m a) -> m a" | |
} | |
, | |
{ name: "composeKleisli" | |
, def: "Bind m => (a -> m b) -> (b -> m c) -> a -> m c" | |
, op: ">==>" | |
} | |
, | |
{ name: "composeKleisliFlipped" | |
, def: "Bind m => (b -> m c) -> (a -> m b) -> a -> m c" | |
, op: "<==<" | |
} | |
, | |
{ name: "ifM" | |
, def: "Bind m => m Boolean -> m a -> m a -> m a" | |
} | |
] | |
instances: [ "((->) r)", "Array" ] | |
} | |
monad : { | |
name: "Monad" | |
info: "Compose computations" | |
laws: | |
[ | |
{ law: "left identity" | |
, example: | |
{ left: "pure x >>= f" | |
, right: "f x" | |
} | |
} | |
, | |
{ law: "right identity" | |
, example: | |
{ left: "x >>= pure" | |
, right: "x" | |
} | |
} | |
] | |
members: | |
[ | |
{ name: "liftM1" | |
, def: "Monad m => (a -> b) -> m a -> m b" | |
} | |
, | |
{ name: "ap" | |
, def: "Monad m => m (a -> b) -> m a -> m b" | |
} | |
, | |
{ name: "whenM" | |
, def: "Monad m => m Boolean -> m Unit -> m Unit" | |
} | |
, | |
{ name: "unlessM" | |
, def: "Monad m => m Boolean -> m Unit -> m Unit" | |
} | |
] | |
parents: [ "bind", "applicative" ] | |
instances: [ "((->) r)", "Array" ] | |
} | |
monadZero : { | |
name: "MonadZero" | |
info: "Compose computations" | |
parents: [ "monad", "alternative" ] | |
laws: | |
[ | |
{ law: "annihilation" | |
, example: | |
{ left: "empty >>= f" | |
, right: "empty" | |
} | |
} | |
] | |
members: | |
{ name: "guard" | |
, def: "MonadZero m => Boolean -> m Unit" | |
} | |
instances: [ "Array" ] | |
} | |
monadPlus : { | |
name: "MonadPluse" | |
info: "Distributivity for Monads" | |
parent: "monadZero" | |
laws: | |
[ | |
{ law: "distributivity" | |
, example: | |
{ left: "(x <|> y) >>= f" | |
, right: "(x >>= f) <|> (y >>= f)" | |
} | |
} | |
] | |
members: | |
{ name: "guard" | |
, def: "MonadZero m => Boolean -> m Unit" | |
} | |
instances: [ "Array" ] | |
} | |
functor : { | |
name: "Functor" | |
info: "Convert and forget" | |
members: | |
[ | |
{ name: "map" | |
, def: "(a -> b) -> f a -> f b" | |
, op: "<$>" | |
, opEmoji: "🚂" | |
, laws : | |
[ | |
{ law: "identity" | |
, example: | |
{ left: "(<$>) id" | |
, right: "id" | |
} | |
} | |
, | |
{ law: "composition" | |
, example: | |
{ left: "(<$>) (f <<< g)" | |
, right: "(f <$>) <<< (g <$>)" | |
} | |
} | |
] | |
} | |
, | |
{ name: "mapFlipped" | |
, def: "Functor f => f a -> (a -> b) -> f b" | |
, op: "<#>" | |
} | |
, | |
{ name: "void" | |
, def: "Functor f => f a -> f Unit" | |
} | |
, | |
{ name: "voidRight" | |
, op: "<$" | |
, def: "Functor f => a -> f b -> f a" | |
} | |
, | |
{ name: "voidLeft" | |
, op: "$>" | |
, def: "Functor f => f a -> b -> f b" | |
} | |
, | |
{ name: "flap" | |
, op: "<@>" | |
, def: "Functor f => f (a -> b) -> a -> f b" | |
} | |
] | |
instances: [ "Array", "((->) r)" ] | |
} | |
apply : { | |
name: "Apply" | |
info: "Unwrap, convert, and wrap again" | |
parent: "functor" | |
members: | |
[ | |
{ name: "apply" | |
, def: "f (a -> b) -> f a -> f b" | |
, op: "<*>" | |
, opEmoji: "🚋" | |
, laws : | |
[ | |
{ law: "ap. composition" | |
, example: | |
{ left: "(<<<) <$> f <*> g <*> h" | |
, right: "f <*> (g <*> h)" | |
} | |
} | |
] | |
} | |
, | |
{ name: "applyFirst" | |
, def: "Apply f => f a -> f b -> f a" | |
, op: "<*" | |
} | |
, | |
{ name: "applySecond" | |
, def: "Apply f => f a -> f b -> f b" | |
, op: "*>" | |
, opEmoji: "👉" | |
} | |
, | |
{ name: "lift2" | |
, def: "Apply f => (a -> b -> c) -> f a -> f b -> f c" | |
} | |
, | |
{ name: "lift3" | |
, def: "Apply f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d" | |
} | |
, | |
{ name: "lift4" | |
, def: "Apply f => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e" | |
} | |
, | |
{ name: "lift5" | |
, def: "Apply f => (a -> b -> c -> d -> e -> g) -> f a -> f b -> f c -> f d -> f e -> f g" | |
} | |
] | |
instances: [ "Array", "((->) r)" ] | |
} | |
applicative : { | |
name: "Applicative" | |
info: "Lift with zero arguments, wrap values" | |
parent: "apply" | |
members: | |
[ | |
{ name: "pure" | |
, def: "a -> f a" | |
, laws : | |
[ | |
{ law: "identity" | |
, example: | |
{ left: "(pure id) <*> v" | |
, right: "v" | |
} | |
} | |
, | |
{ law: "composition" | |
, example: | |
{ left: "(pure <<<) <*> f <*> g <*> h" | |
, right: "f <*> (g <*> h)" | |
} | |
} | |
, | |
{ law: "homomorphism" | |
, example: | |
{ left: "(pure f) <*> (pure x)" | |
, right: "pure (f x)" | |
} | |
} | |
, | |
{ law: "interchange" | |
, example: | |
{ left: "u <*> (pure y)" | |
, right: "(pure ($ y)) <*> u" | |
} | |
} | |
] | |
} | |
, | |
{ name: "liftA1" | |
, def: "Applicative f => (a -> b) -> f a -> f b" | |
} | |
, | |
{ name: "when" | |
, def: "Applicative m => Boolean -> m Unit -> m Unit" | |
} | |
, | |
{ name: "unless" | |
, def: "Applicative m => Boolean -> m Unit -> m Unit" | |
} | |
] | |
instances: [ "Array", "((->) r)" ] | |
} | |
alternative : { | |
name: "Alternative" | |
info: "To have both Plus and Applicative" | |
parents: [ "plus", "applicative" ] | |
laws: | |
[ | |
{ law: "distributivity" | |
, example: | |
{ left: "(f <|> g) <*> x" | |
, right: "(f <*> x) <|> (g <*> x)" | |
} | |
} | |
, | |
{ law: "annihilation" | |
, example: | |
{ left: "empty <*> f" | |
, right: "empty" | |
} | |
} | |
] | |
} | |
unit : { | |
name: "Unit" | |
info: "No computation needed" | |
package: "Data" | |
members: | |
[ | |
{ name: "unit" | |
, def: "Unit" | |
} | |
] | |
instances: [ "Show Unit" ] | |
} | |
void : { | |
name: "Void" | |
info: "Uninhabited data type" | |
package: "Data" | |
members: | |
[ | |
{ name: "absurd" | |
, def: "Void -> a" | |
, opEmoji: "💣" | |
} | |
] | |
instances: [ "Show Void" ] | |
} | |
function : { | |
name: "Function" | |
info: "Helpers for the core functions" | |
package: "Data" | |
members: [ | |
{ name: "flip" | |
, def: "(a -> b -> c) -> b -> a -> c" | |
} | |
, | |
{ name: "const" | |
, def: "a -> b -> a" | |
} | |
, | |
{ name: "apply" | |
, def: "(a -> b) -> a -> b" | |
, op: "$" | |
, opEmoji: "💨" | |
} | |
, | |
{ name: "applyFlipped" | |
, def: "a -> (a -> b) -> b" | |
, op: "#" | |
} | |
, | |
{ name: "on" | |
, def: "(b -> b -> c) -> (a -> b) -> a -> a -> c" | |
} | |
] | |
} | |
naturalTransformation : { | |
name: "NaturalTransformation" | |
info: "Mapping b/w type constructors with no manipulation on inner value" | |
package: "Data" | |
members: [ | |
{ name: "NaturalTransformation" | |
, def: "f a -> g a" | |
, op: "~>" | |
, opEmoji: "🐛" | |
} | |
] | |
} | |
semigroup : { | |
name: "Semigroup" | |
info: "Associativity" | |
package: "Data" | |
members: [ | |
{ name: "append" | |
, def: "a -> a -> a" | |
, op: "<>" | |
, opEmoji: "🙏" | |
, laws: | |
[ | |
{ law: "associativity" | |
, example: | |
{ left: "(x <> y) <> z" | |
, right: "x <> (y <> z)" | |
} | |
} | |
] | |
} | |
] | |
instances: [ "String", "Unit", "Void", "Array a", "Semigroup s' => Semigroup (s -> s')" ] | |
} | |
monoid : { | |
name: "Monoid" | |
parent: "semigroup" | |
info: "Folding empty collection" | |
members: | |
[ | |
{ name: "mempty" | |
, def: "m" | |
, laws: | |
[ | |
{ law: "associativity" | |
, example: | |
{ left: "mempty <> x" | |
, middle: "x <> mempty" | |
, right: "x forall x" | |
} | |
} | |
] | |
} | |
, | |
{ name: "power" | |
, def: "Monoid m => m -> Int -> m" | |
} | |
, | |
{ name: "guard" | |
, def: "Monoid m => Boolean -> m -> m" | |
} | |
] | |
instances: [ "Unit", "Ordering", "Number", "String", "Array a", "Monoid b => Monoid (a -> b)" ] | |
} | |
eq : { | |
name: "Eq" | |
package: "Data" | |
info: "Equality" | |
members: | |
[ | |
{ name: "eq" | |
, def: "a -> a -> Boolean" | |
, op: "==" | |
, laws: | |
[ | |
{ law: "reflexivity" | |
, example: | |
{ left: "x == x" | |
, right: "true" | |
} | |
} | |
, | |
{ law: "symmetry" | |
, example: | |
{ left: "x == y" | |
, right: "y == x" | |
} | |
} | |
, | |
{ law: "transitivity" | |
, example: | |
{ fact: "(x == y) and (y == z)" | |
, conclusion: "y == x" | |
} | |
} | |
] | |
} | |
, | |
{ name: "notEq" | |
, op: "/=" | |
, def: "Eq a => a -> a -> Boolean" | |
} | |
] | |
instances: | |
[ "Boolean", "Int", "Number", "Char", "String", "Unit", "Void", "Eq a => Eq (Array a)" ] | |
} | |
ord : { | |
name: "Ord" | |
info: "Ordering" | |
parent: "eq" | |
members: | |
[ | |
{ name: "compart" | |
, def: "a -> a -> Ordering" | |
, op: "==" | |
, laws: | |
[ | |
{ law: "reflexivity" | |
, example: | |
{ fact: "a <= a" | |
} | |
} | |
, | |
{ law: "antisymmetry" | |
, example: | |
{ fact: "(a <= b) and (b <= a)" | |
, conclusion: "a = b" | |
} | |
} | |
, | |
{ law: "transitivity" | |
, example: | |
{ fact: "(a <= b) and (b <= c)" | |
, conclusion: "a <= c" | |
} | |
} | |
] | |
} | |
, | |
{ name: "lessThan" | |
, op: "<" | |
, def: "Ord a => a -> a -> Boolean" | |
} | |
, | |
{ name: "greaterThan" | |
, op: ">" | |
, def: "Ord a => a -> a -> Boolean" | |
} | |
, | |
{ name: "lessThanOrEq" | |
, op: "<=" | |
, def: "Ord a => a -> a -> Boolean" | |
} | |
, | |
{ name: "greaterThanOrEq" | |
, op: ">=" | |
, def: "Ord a => a -> a -> Boolean" | |
} | |
, | |
{ name: "min" | |
, def: "Ord a => a -> a -> a" | |
} | |
, | |
{ name: "max" | |
, def: "Ord a => a -> a -> a" | |
} | |
, | |
{ name: "clamp" | |
, def: "Ord a => a -> a -> a -> a" | |
} | |
, | |
{ name: "between" | |
, def: "Ord a => a -> a -> a -> Boolean" | |
} | |
, | |
{ name: "abs" | |
, def: "(Ord a, Ring a) => a -> a" | |
} | |
, | |
{ name: "signum" | |
, def: "(Ord a, Ring a) => a -> a" | |
} | |
, | |
{ name: "comparing" | |
, def: "Ord b => (a -> b) -> (a -> a -> Ordering)" | |
} | |
] | |
} | |
bounded : { | |
name: "Bounded" | |
parent: "ord" | |
info: "Have upper and lower boundary" | |
package: "Data" | |
laws: | |
[ | |
{ name: "bounded" | |
, fact: "bottom <= a <= top" | |
} | |
] | |
members: | |
[ | |
{ name: "top" | |
, def: "a" | |
} | |
, | |
{ name: "bottom" | |
, def: "a" | |
} | |
] | |
instances: [ "Boolean", "Int", "Char", "Ordering", "Unit" ] | |
} | |
ordering : { | |
name: "Ordering" | |
info: "Just to know the order" | |
values: [ "LT", "GT", "EQ" ] | |
members: | |
[ | |
{ name: "invert" | |
, def: "Ordering -> Ordering" | |
} | |
] | |
instances: [ "Eq Ordering", "Semigroup Ordering", "Show Ordering" ] | |
} | |
show : { | |
name: "Show" | |
info: "Displaying values" | |
package: "Data" | |
members: | |
[ | |
{ name: "show" | |
, def: "a -> String" | |
} | |
] | |
instances: [ "Show Boolean", "Show Int", "Show Number", "Show Char", "Show String", "Show a => Show (Array a)" ] | |
} | |
heytingAlgebra : { | |
name: "HeytingAlgebra" | |
info: "Bounded lattices, boolean starters" | |
members: | |
[ | |
{ name: "ff" | |
, def: "a" | |
} | |
, | |
{ name: "tt" | |
, def: "a" | |
} | |
, | |
{ name: "implies" | |
, def: "a -> a -> a" | |
} | |
, | |
{ name: "conj" | |
, def: "a -> a -> a" | |
, op: "&&" | |
} | |
, | |
{ name: "disj" | |
, def: "a -> a -> a" | |
, op: "||" | |
} | |
, | |
{ name: "not" | |
, def: "a" | |
} | |
] | |
laws: | |
[ | |
{ | |
law: "associativity" | |
examples: | |
[ { left: "a || (b || c)", right: "(a || b) || c" } | |
, { left: "a && (b && c)", right: "(a && b) && c" } | |
] | |
} | |
, | |
{ | |
law: "commutativity" | |
examples: | |
[ { left: "a || b", right: "b || a" } | |
, { left: "a && b", right: "b && a" } | |
] | |
} | |
, | |
{ | |
law: "absorption" | |
examples: | |
[ { left: "a || (a && b)", right: "a" } | |
, { left: "a && a", right: "a" } | |
] | |
} | |
, | |
{ | |
law: "idempotent" | |
examples: | |
[ { left: "a || a", right: "a" } | |
, { left: "a && (a || b)", right: "a" } | |
] | |
} | |
, | |
{ | |
law: "identity" | |
examples: | |
[ { left: "a || ff", right: "a" } | |
, { left: "a && tt", right: "a" } | |
] | |
} | |
, | |
{ | |
law: "implication" | |
examples: | |
[ { left: "a `implies` a", right: "tt" } | |
, { left: "a && (a `implies` b)", right: "a && b" } | |
, { left: "b && (a `implies` b)", right: "b" } | |
, { left: "a `implies` (b && c)", right: "(a `implies` b) && (a `implies` c)" } | |
] | |
} | |
, | |
{ | |
law: "complemented" | |
example: { left: "not a", right: "a `implies` ff" } | |
} | |
] | |
instances: [ "Boolean", "Unit", "(a -> b)" ] | |
} | |
booleanAlgebra : { | |
name: "BooleanAlgebra" | |
info: "Behave like boolean" | |
parent: "heytingAlgebra" | |
laws: | |
[ | |
{ name: "excluded middle" | |
, def: "a || not a == tt" | |
} | |
] | |
instances: [ "Boolean", "Unit", "BooleanAlgebra b => BooleanAlgebra (a -> b)" ] | |
} | |
boolean : { | |
name: "Boolean" | |
info: "Helpers for boolean types" | |
members: | |
[ | |
{ name: "otherwise" | |
, def: "Boolean" | |
} | |
] | |
} | |
divisionRing : { | |
name: "DivisionRing" | |
parent: "ring" | |
info: "Non-zero rings in which every non-zero element has a multiplicative inverse / skew fields" | |
members: | |
[ | |
{ name: "recip" | |
, def: "a -> a" | |
, laws: | |
[ | |
{ law: "Non-zero Ring" | |
, fact: "one /= zero" | |
} | |
, | |
{ law: "Non-zero multplicative inverse" | |
, left: "recip a * a" | |
, middle: "a * recip a" | |
, right: "one forall a /= 0" | |
} | |
] | |
} | |
, | |
{ name: "leftDiv" | |
, def: "DivisionRing a => a -> a -> a" | |
} | |
, | |
{ name: "rightDiv" | |
, def: "DivisionRing a => a -> a -> a" | |
} | |
] | |
instances: [ "Number" ] | |
} | |
semiring : { | |
name: "Semiring" | |
info: "Sum and Multiply (a.k.a. extended Monoid)" | |
members: | |
[ | |
{ name: "add" | |
, def: "a -> a -> a" | |
, op: "+" | |
} | |
, | |
{ name: "zero" | |
, def: "a" | |
} | |
, | |
{ name: "mul" | |
, def: "a -> a -> a" | |
, op: "*" | |
} | |
, | |
{ name: "one" | |
, def: "a" | |
} | |
] | |
laws: | |
[ | |
{ law: "associativity" | |
, left: "(a + b) + c" | |
, right: "a + (b + c)" | |
} | |
, | |
{ law: "identity" | |
, left: "zero + a" | |
, middle: "a + zero" | |
, right: "a" | |
} | |
, | |
{ law: "commutative" | |
, left: "a + b" | |
, right: "b + a" | |
} | |
, | |
{ law: "associativity" | |
, left: "(a + b) * c" | |
, right: "a * (b * c)" | |
} | |
, | |
{ law: "identity" | |
, left: "one * a" | |
, middle: "a * one" | |
, right: "a" | |
} | |
, | |
{ law: "left distributivity" | |
, left: "a * (b + c)" | |
, right: "(a * b) + (a * c)" | |
} | |
, | |
{ law: "right distributivity" | |
, left: "a + (b * c)" | |
, right: "(a * c) + (b * c)" | |
} | |
, | |
{ law: "annihilation" | |
, left: "zero * a" | |
, middle: "a * zero" | |
, right: "zero" | |
} | |
] | |
instances: [ "Int", "Number", "Semiring b => Semiring (a -> b)" ] | |
} | |
ring : { | |
parent: "semiring" | |
name: "Ring" | |
info: "Subtraction" | |
members: | |
[ | |
{ name: "sub" | |
, def: "a -> a -> a" | |
, op: "-" | |
, laws: | |
[ | |
{ law: "Additive inverse" | |
, left: "a - a" | |
, middle: "zero - a" | |
, right: "zero" | |
} | |
] | |
} | |
, | |
{ name: "negate" | |
, def: "Ring a => a -> a" | |
} | |
] | |
instances: [ "Int", "Number", "Unit", "Ring b => Ring (a -> b)" ] | |
} | |
commutativeRing : { | |
name: "CommutativeRing" | |
info: "Multiplication behaves commutatively" | |
parent: "ring" | |
laws: | |
[ | |
{ law: "commutative" | |
, left: "a * b" | |
, right: "b * a" | |
} | |
] | |
instances: [ "Int", "Number", "Unit", "CommutativeRing b => CommutativeRing (a -> b)" ] | |
} | |
euclidianRing : { | |
name: "EuclidianRing" | |
info: "Divide and Conquer" | |
parent: "commutativeRing" | |
members: | |
[ | |
{ name: "degree" | |
, def: "a -> Int" | |
} | |
, | |
{ name: "div" | |
, def: "a -> a -> a" | |
, op: "/" | |
} | |
, | |
{ name: "mode" | |
, def: "a -> a -> a" | |
} | |
, | |
{ name: "gcd" | |
, def: "Eq a => EuclideanRing a => a -> a -> a" | |
} | |
, | |
{ name: "lcm" | |
, def: "Eq a => EuclideanRing a => a -> a -> a" | |
} | |
] | |
laws: | |
[ | |
{ law: "integral domain" | |
, fact: "(a /= 0) and (b /= 0)" | |
, conclusion: "a * b /= 0" | |
} | |
, | |
{ law: "multiplicative Euclidean function" | |
, right: "a" | |
, left: "(a / b) * b + (a `mod` b)" | |
, conditions: | |
[ "degree a > 0" | |
, "degree a <= degree (a * b)" | |
] | |
} | |
] | |
instances: [ "Int", "Number" ] | |
} | |
field : { | |
info: "Commutative fields" | |
parent: "euclidianRing" | |
laws: | |
[ | |
{ law: "non-zero multiplicative inverse" | |
, right: "a `mod` b" | |
, left: "0" | |
} | |
] | |
instances: [ "Int", "Number" ] | |
} | |
endo : { | |
name: "Endo" | |
info: "By itself" | |
package: "Data.Monoid" | |
statements: | |
[ | |
{ left: "Endo f <> Endo g" | |
, right: "Endo (f <<< g)" | |
} | |
, | |
{ left: "mempty :: Endo _" | |
, right: "Endo id" | |
} | |
] | |
instances: [ "Newtype (Endo a) _", "Invariant Endo", "Semigroup (Endo a)", "Monoid (Endo a)" ] | |
} | |
dual : { | |
name: "Dual" | |
info: "Monoid under dualism" | |
package: "Data.Monoid" | |
statements: | |
[ | |
{ left: "Dual x <> Dual y" | |
, right: "Dual (y <> x)" | |
} | |
, | |
{ left: "mempty :: Dual _" | |
, right: "Dual mempty" | |
} | |
] | |
instances: [ "Newtype (Dual a) _", "Eq a => Eq (Dual a)", "Ord a => Ord (Dual a)", "Bounded a => Bounded (Dual a)", "Functor Dual", "Invariant Dual", "Apply Dual", "Applicative Dual", "Bind Dual", "Monad Dual", "Extend Dual", "Comonad Dual", "Show a => Show (Dual a)", "Semigroup a => Semigroup (Dual a)", "Monoid a => Monoid (Dual a)" ] | |
} | |
additive : { | |
name: "Additive" | |
info: "May be added to something" | |
package: "Data.Monoid" | |
statements: | |
[ | |
{ left: "Additive x <> Additive y" | |
, right: "Additive (x + y)" | |
} | |
, | |
{ left: "mempty :: Additive _" | |
, right: "Additive zero" | |
} | |
] | |
instances: [ "Newtype (Additive a) _", "Eq a => Eq (Additive a)", "Ord a => Ord (Additive a)", "Bounded a => Bounded (Additive a)", "Functor Additive", "Invariant Additive", "Apply Additive", "Applicative Additive", "Bind Additive", "Monad Additive", "Extend Additive", "Comonad Additive", "Show a => Show (Additive a)", "Semiring a => Semigroup (Additive a)", "Semiring a => Monoid (Additive a)" ] | |
} | |
multiplicative : { | |
name: "Multiplicative" | |
info: "May be multiplied on something" | |
package: "Data.Monoid" | |
statements: | |
[ | |
{ left: "Multiplicative x <> Multiplicative y" | |
, right: "Multiplicative (x * y)" | |
} | |
, | |
{ left: "mempty :: Multiplicative _" | |
, right: "Multiplicative one" | |
} | |
] | |
instances: [ "Newtype (Multiplicative a) _", "Eq a => Eq (Multiplicative a)", "Ord a => Ord (Multiplicative a)", "Bounded a => Bounded (Multiplicative a)", "Functor Multiplicative", "Invariant Multiplicative", "Apply Multiplicative", "Applicative Multiplicative", "Bind Multiplicative", "Monad Multiplicative", "Extend Multiplicative", "Comonad Multiplicative", "Show a => Show (Multiplicative a)", "Semiring a => Semigroup (Multiplicative a)", "Semiring a => Monoid (Multiplicative a)" ] | |
} | |
conj : { | |
name: "Multiplicative" | |
info: "Monoid under conjunction" | |
package: "Data.Monoid" | |
statements: | |
[ | |
{ left: "Conj x <> Conj y" | |
, right: "Conj (x && y)" | |
} | |
, | |
{ left: "mempty :: Conj _" | |
, right: "Conj top" | |
} | |
] | |
instances: [ "Newtype (Conj a) _", "Eq a => Eq (Conj a)", "Ord a => Ord (Conj a)", "Bounded a => Bounded (Conj a)", "Functor Conj", "Invariant Conj", "Apply Conj", "Applicative Conj", "Bind Conj", "Monad Conj", "Extend Conj", "Comonad Conj", "Show a => Show (Conj a)", "HeytingAlgebra a => Semigroup (Conj a)", "HeytingAlgebra a => Monoid (Conj a)", "HeytingAlgebra a => Semiring (Conj a)" ] | |
} | |
disj : { | |
name: "Disj" | |
info: "Monoid under disjunction" | |
package: "Data.Monoid" | |
statements: | |
[ | |
{ left: "Conj x <> Conj y" | |
, right: "Disj (x || y)" | |
} | |
, | |
{ left: "mempty :: Disj _" | |
, right: "Disj bottom" | |
} | |
] | |
instances: [ "Newtype (Disj a) _", "Eq a => Eq (Disj a)", "Ord a => Ord (Disj a)", "Bounded a => Bounded (Disj a)", "Functor Disj", "Invariant Disj", "Apply Disj", "Applicative Disj", "Bind Disj", "Monad Disj", "Extend Disj", "Comonad Disj", "Show a => Show (Disj a)", "HeytingAlgebra a => Semigroup (Disj a)", "HeytingAlgebra a => Monoid (Disj a)", "HeytingAlgebra a => Semiring (Disj a)" ] | |
} | |
alternate : { | |
name: "Alternate" | |
info: "Monoid and Semigroup instances corresponding to Plus and Alt for f" | |
package: "Data.Monoid" | |
statements: | |
[ | |
{ left: "Alternate fx <> Alternate fy" | |
, right: "Alternate (fx <|> fy)" | |
} | |
, | |
{ left: "mempty :: Alternate _" | |
, right: "Alternate empty" | |
} | |
] | |
instances: [ "Newtype (Alternate f a) _", "Eq a => Eq (Alternate f)", "Ord a => Ord (Alternate a)", "Bounded a => Bounded (Alternate a)", "Functor f => Functor Alternate", "Invariant f => Invariant (Alternate f)", "Apply f => Apply Alternate", "Applicative f => Applicative Alternate", "Bind f => Bind Alternate", "Monad Additive", "Extend Additive", "Comonad Additive", "Show (Alternate f a)", "Semigroup (Alternate f a)", "Monoid (Alternate f a)" ] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"plus": { | |
"name": "Plus", | |
"info": "Left and Right identity for Alt", | |
"parent": "alt", | |
"package": "Control*", | |
"members": [ | |
{ | |
"name": "empty", | |
"def": "f a", | |
"laws": [ | |
{ | |
"law": "associativity", | |
"example": { | |
"left": "(x \u003c|\u003e y) \u003c|\u003e z", | |
"right": "x \u003c|\u003e (y \u003c|\u003e z)" | |
} | |
}, | |
{ | |
"law": "distributivity", | |
"example": { | |
"left": "f \u003c$\u003e (x \u003c|\u003e y)", | |
"right": "(f \u003c$\u003e x) \u003c|\u003e (f \u003c$\u003e y)" | |
} | |
} | |
] | |
} | |
], | |
"instances": [ | |
"Array" | |
] | |
}, | |
"comonad": { | |
"name": "Comonad", | |
"info": "Left and Right identity for Alt", | |
"parent": "extend", | |
"package": "Control*", | |
"members": [ | |
{ | |
"name": "extract", | |
"def": "w a -\u003e a", | |
"laws": [ | |
{ | |
"law": "left identity", | |
"example": { | |
"left": "extract \u003c\u003c== xs", | |
"right": "xs" | |
} | |
}, | |
{ | |
"law": "right identity", | |
"example": { | |
"left": "extract (f \u003c\u003c== xs)", | |
"right": "f xs" | |
} | |
} | |
] | |
} | |
], | |
"instances": [] | |
}, | |
"semigroupoid": { | |
"name": "Semigroupoid", | |
"info": "Category without identity", | |
"package": "Control", | |
"members": [ | |
{ | |
"name": "compose", | |
"def": "a c d -\u003e a b c -\u003e a b d", | |
"op": "\u003c\u003c\u003c", | |
"opEmoji": "🔙", | |
"laws": [ | |
{ | |
"law": "associativity", | |
"example": { | |
"left": "p \u003c\u003c\u003c (q \u003c\u003c\u003c r)", | |
"right": "(p \u003c\u003c\u003c q) \u003c\u003c\u003c r" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "composeFlipped", | |
"def": "Semigroupoid a =\u003e a b c -\u003e a c d -\u003e a b d", | |
"op": "\u003e\u003e\u003e", | |
"opEmoji": "🔜" | |
} | |
], | |
"instances": [] | |
}, | |
"category": { | |
"name": "Category", | |
"info": "Objects and composable morphisms with their identity", | |
"parent": "semigroupoid", | |
"package": "Control", | |
"members": [ | |
{ | |
"name": "id", | |
"def": "a t t", | |
"laws": [ | |
{ | |
"law": "identity", | |
"example": { | |
"left": "id \u003c\u003c\u003c p", | |
"middle": "p \u003c\u003c\u003c id", | |
"right": "p" | |
} | |
} | |
] | |
} | |
], | |
"instances": [ | |
"(-\u003e)" | |
] | |
}, | |
"lazy": { | |
"name": "Lazy", | |
"info": "Deferred operations", | |
"package": "Control*", | |
"members": [ | |
{ | |
"name": "defer", | |
"def": "(Unit -\u003e l) -\u003e l" | |
}, | |
{ | |
"name": "fix", | |
"def": "Lazy l =\u003e (l -\u003e l) -\u003e l" | |
} | |
], | |
"instances": [ | |
"(a -\u003e b)", | |
"Unit" | |
] | |
}, | |
"alt": { | |
"name": "Alt", | |
"info": "Associative operation on a constructor", | |
"parent": "functor", | |
"package": "Control*", | |
"members": [ | |
{ | |
"name": "alt", | |
"def": "f a -\u003e f a -\u003e f a", | |
"op": "\u003c|\u003e", | |
"opEmoji": "🔗", | |
"laws": [ | |
{ | |
"law": "associativity", | |
"example": { | |
"left": "(x \u003c|\u003e y) \u003c|\u003e z", | |
"right": "x \u003c|\u003e (y \u003c|\u003e z)" | |
} | |
}, | |
{ | |
"law": "distributivity", | |
"example": { | |
"left": "f \u003c$\u003e (x \u003c|\u003e y)", | |
"right": "(f \u003c$\u003e x) \u003c|\u003e (f \u003c$\u003e y)" | |
} | |
} | |
] | |
} | |
], | |
"instances": [ | |
"Array" | |
] | |
}, | |
"extend": { | |
"name": "Extend", | |
"info": "Extend local computation to a global one", | |
"parent": "functor", | |
"package": "Control*", | |
"members": [ | |
{ | |
"name": "extend", | |
"def": "m a -\u003e (a -\u003e m b) -\u003e m b", | |
"op": "\u003c\u003c==", | |
"laws": [ | |
{ | |
"law": "associativity", | |
"example": { | |
"left": "extend f \u003c\u003c\u003c extend g", | |
"right": "extend (f \u003c\u003c\u003c extend g)" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "extendFlipped", | |
"def": "Extend w =\u003e w a -\u003e (w a -\u003e b) -\u003e w b", | |
"op": "==\u003e\u003e" | |
}, | |
{ | |
"name": "composeCoKleisli", | |
"def": "Extend w =\u003e (w a -\u003e b) -\u003e (w b -\u003e c) -\u003e w a -\u003e c", | |
"op": "=\u003e=" | |
}, | |
{ | |
"name": "composeCoKleisliFlipped", | |
"def": "Extend w =\u003e (w b -\u003e c) -\u003e (w a -\u003e b) -\u003e w a -\u003e c", | |
"op": "=\u003c=" | |
}, | |
{ | |
"name": "duplicate", | |
"def": "Extend w =\u003e w a -\u003e w (w a)" | |
} | |
], | |
"instances": [ | |
"Semigroup w =\u003e Extend ((-\u003e) w)", | |
"Array" | |
] | |
}, | |
"bind": { | |
"name": "Bind", | |
"info": "Compose computations", | |
"parent": "apply", | |
"members": [ | |
{ | |
"name": "bind", | |
"def": "m a -\u003e (a -\u003e m b) -\u003e m b", | |
"op": "\u003e\u003e=", | |
"opEmoji": "🎉", | |
"laws": [ | |
{ | |
"law": "associativity", | |
"example": { | |
"left": "(x \u003e\u003e= f) \u003e\u003e= g", | |
"right": "x \u003e\u003e= (\\k -\u003e f k \u003e\u003e= g)" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "bindFlipped", | |
"def": "Bind m =\u003e (a -\u003e m b) -\u003e m a -\u003e m b", | |
"op": "==\u003c\u003c" | |
}, | |
{ | |
"name": "join", | |
"def": "Bind m =\u003e m (m a) -\u003e m a" | |
}, | |
{ | |
"name": "composeKleisli", | |
"def": "Bind m =\u003e (a -\u003e m b) -\u003e (b -\u003e m c) -\u003e a -\u003e m c", | |
"op": "\u003e==\u003e" | |
}, | |
{ | |
"name": "composeKleisliFlipped", | |
"def": "Bind m =\u003e (b -\u003e m c) -\u003e (a -\u003e m b) -\u003e a -\u003e m c", | |
"op": "\u003c==\u003c" | |
}, | |
{ | |
"name": "ifM", | |
"def": "Bind m =\u003e m Boolean -\u003e m a -\u003e m a -\u003e m a" | |
} | |
], | |
"instances": [ | |
"((-\u003e) r)", | |
"Array" | |
] | |
}, | |
"monad": { | |
"name": "Monad", | |
"info": "Compose computations", | |
"laws": [ | |
{ | |
"law": "left identity", | |
"example": { | |
"left": "pure x \u003e\u003e= f", | |
"right": "f x" | |
} | |
}, | |
{ | |
"law": "right identity", | |
"example": { | |
"left": "x \u003e\u003e= pure", | |
"right": "x" | |
} | |
} | |
], | |
"members": [ | |
{ | |
"name": "liftM1", | |
"def": "Monad m =\u003e (a -\u003e b) -\u003e m a -\u003e m b" | |
}, | |
{ | |
"name": "ap", | |
"def": "Monad m =\u003e m (a -\u003e b) -\u003e m a -\u003e m b" | |
}, | |
{ | |
"name": "whenM", | |
"def": "Monad m =\u003e m Boolean -\u003e m Unit -\u003e m Unit" | |
}, | |
{ | |
"name": "unlessM", | |
"def": "Monad m =\u003e m Boolean -\u003e m Unit -\u003e m Unit" | |
} | |
], | |
"parents": [ | |
"bind", | |
"applicative" | |
], | |
"instances": [ | |
"((-\u003e) r)", | |
"Array" | |
] | |
}, | |
"monadZero": { | |
"name": "MonadZero", | |
"info": "Compose computations", | |
"parents": [ | |
"monad", | |
"alternative" | |
], | |
"laws": [ | |
{ | |
"law": "annihilation", | |
"example": { | |
"left": "empty \u003e\u003e= f", | |
"right": "empty" | |
} | |
} | |
], | |
"members": { | |
"name": "guard", | |
"def": "MonadZero m =\u003e Boolean -\u003e m Unit" | |
}, | |
"instances": [ | |
"Array" | |
] | |
}, | |
"monadPlus": { | |
"name": "MonadPluse", | |
"info": "Distributivity for Monads", | |
"parent": "monadZero", | |
"laws": [ | |
{ | |
"law": "distributivity", | |
"example": { | |
"left": "(x \u003c|\u003e y) \u003e\u003e= f", | |
"right": "(x \u003e\u003e= f) \u003c|\u003e (y \u003e\u003e= f)" | |
} | |
} | |
], | |
"members": { | |
"name": "guard", | |
"def": "MonadZero m =\u003e Boolean -\u003e m Unit" | |
}, | |
"instances": [ | |
"Array" | |
] | |
}, | |
"functor": { | |
"name": "Functor", | |
"info": "Convert and forget", | |
"members": [ | |
{ | |
"name": "map", | |
"def": "(a -\u003e b) -\u003e f a -\u003e f b", | |
"op": "\u003c$\u003e", | |
"opEmoji": "🚂", | |
"laws": [ | |
{ | |
"law": "identity", | |
"example": { | |
"left": "(\u003c$\u003e) id", | |
"right": "id" | |
} | |
}, | |
{ | |
"law": "composition", | |
"example": { | |
"left": "(\u003c$\u003e) (f \u003c\u003c\u003c g)", | |
"right": "(f \u003c$\u003e) \u003c\u003c\u003c (g \u003c$\u003e)" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "mapFlipped", | |
"def": "Functor f =\u003e f a -\u003e (a -\u003e b) -\u003e f b", | |
"op": "\u003c#\u003e" | |
}, | |
{ | |
"name": "void", | |
"def": "Functor f =\u003e f a -\u003e f Unit" | |
}, | |
{ | |
"name": "voidRight", | |
"op": "\u003c$", | |
"def": "Functor f =\u003e a -\u003e f b -\u003e f a" | |
}, | |
{ | |
"name": "voidLeft", | |
"op": "$\u003e", | |
"def": "Functor f =\u003e f a -\u003e b -\u003e f b" | |
}, | |
{ | |
"name": "flap", | |
"op": "\u003c@\u003e", | |
"def": "Functor f =\u003e f (a -\u003e b) -\u003e a -\u003e f b" | |
} | |
], | |
"instances": [ | |
"Array", | |
"((-\u003e) r)" | |
] | |
}, | |
"apply": { | |
"name": "Apply", | |
"info": "Unwrap, convert, and wrap again", | |
"parent": "functor", | |
"members": [ | |
{ | |
"name": "apply", | |
"def": "f (a -\u003e b) -\u003e f a -\u003e f b", | |
"op": "\u003c*\u003e", | |
"opEmoji": "🚋", | |
"laws": [ | |
{ | |
"law": "ap. composition", | |
"example": { | |
"left": "(\u003c\u003c\u003c) \u003c$\u003e f \u003c*\u003e g \u003c*\u003e h", | |
"right": "f \u003c*\u003e (g \u003c*\u003e h)" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "applyFirst", | |
"def": "Apply f =\u003e f a -\u003e f b -\u003e f a", | |
"op": "\u003c*" | |
}, | |
{ | |
"name": "applySecond", | |
"def": "Apply f =\u003e f a -\u003e f b -\u003e f b", | |
"op": "*\u003e", | |
"opEmoji": "👉" | |
}, | |
{ | |
"name": "lift2", | |
"def": "Apply f =\u003e (a -\u003e b -\u003e c) -\u003e f a -\u003e f b -\u003e f c" | |
}, | |
{ | |
"name": "lift3", | |
"def": "Apply f =\u003e (a -\u003e b -\u003e c -\u003e d) -\u003e f a -\u003e f b -\u003e f c -\u003e f d" | |
}, | |
{ | |
"name": "lift4", | |
"def": "Apply f =\u003e (a -\u003e b -\u003e c -\u003e d -\u003e e) -\u003e f a -\u003e f b -\u003e f c -\u003e f d -\u003e f e" | |
}, | |
{ | |
"name": "lift5", | |
"def": "Apply f =\u003e (a -\u003e b -\u003e c -\u003e d -\u003e e -\u003e g) -\u003e f a -\u003e f b -\u003e f c -\u003e f d -\u003e f e -\u003e f g" | |
} | |
], | |
"instances": [ | |
"Array", | |
"((-\u003e) r)" | |
] | |
}, | |
"applicative": { | |
"name": "Applicative", | |
"info": "Lift with zero arguments, wrap values", | |
"parent": "apply", | |
"members": [ | |
{ | |
"name": "pure", | |
"def": "a -\u003e f a", | |
"laws": [ | |
{ | |
"law": "identity", | |
"example": { | |
"left": "(pure id) \u003c*\u003e v", | |
"right": "v" | |
} | |
}, | |
{ | |
"law": "composition", | |
"example": { | |
"left": "(pure \u003c\u003c\u003c) \u003c*\u003e f \u003c*\u003e g \u003c*\u003e h", | |
"right": "f \u003c*\u003e (g \u003c*\u003e h)" | |
} | |
}, | |
{ | |
"law": "homomorphism", | |
"example": { | |
"left": "(pure f) \u003c*\u003e (pure x)", | |
"right": "pure (f x)" | |
} | |
}, | |
{ | |
"law": "interchange", | |
"example": { | |
"left": "u \u003c*\u003e (pure y)", | |
"right": "(pure ($ y)) \u003c*\u003e u" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "liftA1", | |
"def": "Applicative f =\u003e (a -\u003e b) -\u003e f a -\u003e f b" | |
}, | |
{ | |
"name": "when", | |
"def": "Applicative m =\u003e Boolean -\u003e m Unit -\u003e m Unit" | |
}, | |
{ | |
"name": "unless", | |
"def": "Applicative m =\u003e Boolean -\u003e m Unit -\u003e m Unit" | |
} | |
], | |
"instances": [ | |
"Array", | |
"((-\u003e) r)" | |
] | |
}, | |
"alternative": { | |
"name": "Alternative", | |
"info": "To have both Plus and Applicative", | |
"parents": [ | |
"plus", | |
"applicative" | |
], | |
"laws": [ | |
{ | |
"law": "distributivity", | |
"example": { | |
"left": "(f \u003c|\u003e g) \u003c*\u003e x", | |
"right": "(f \u003c*\u003e x) \u003c|\u003e (g \u003c*\u003e x)" | |
} | |
}, | |
{ | |
"law": "annihilation", | |
"example": { | |
"left": "empty \u003c*\u003e f", | |
"right": "empty" | |
} | |
} | |
] | |
}, | |
"unit": { | |
"name": "Unit", | |
"info": "No computation needed", | |
"package": "Data", | |
"members": [ | |
{ | |
"name": "unit", | |
"def": "Unit" | |
} | |
], | |
"instances": [ | |
"Show Unit" | |
] | |
}, | |
"void": { | |
"name": "Void", | |
"info": "Uninhabited data type", | |
"package": "Data", | |
"members": [ | |
{ | |
"name": "absurd", | |
"def": "Void -\u003e a", | |
"opEmoji": "💣" | |
} | |
], | |
"instances": [ | |
"Show Void" | |
] | |
}, | |
"function": { | |
"name": "Function", | |
"info": "Helpers for the core functions", | |
"package": "Data", | |
"members": [ | |
{ | |
"name": "flip", | |
"def": "(a -\u003e b -\u003e c) -\u003e b -\u003e a -\u003e c" | |
}, | |
{ | |
"name": "const", | |
"def": "a -\u003e b -\u003e a" | |
}, | |
{ | |
"name": "apply", | |
"def": "(a -\u003e b) -\u003e a -\u003e b", | |
"op": "$", | |
"opEmoji": "💨" | |
}, | |
{ | |
"name": "applyFlipped", | |
"def": "a -\u003e (a -\u003e b) -\u003e b", | |
"op": "#" | |
}, | |
{ | |
"name": "on", | |
"def": "(b -\u003e b -\u003e c) -\u003e (a -\u003e b) -\u003e a -\u003e a -\u003e c" | |
} | |
] | |
}, | |
"naturalTransformation": { | |
"name": "NaturalTransformation", | |
"info": "Mapping b/w type constructors with no manipulation on inner value", | |
"package": "Data", | |
"members": [ | |
{ | |
"name": "NaturalTransformation", | |
"def": "f a -\u003e g a", | |
"op": "~\u003e", | |
"opEmoji": "🐛" | |
} | |
] | |
}, | |
"semigroup": { | |
"name": "Semigroup", | |
"info": "Associativity", | |
"package": "Data", | |
"members": [ | |
{ | |
"name": "append", | |
"def": "a -\u003e a -\u003e a", | |
"op": "\u003c\u003e", | |
"opEmoji": "🙏", | |
"laws": [ | |
{ | |
"law": "associativity", | |
"example": { | |
"left": "(x \u003c\u003e y) \u003c\u003e z", | |
"right": "x \u003c\u003e (y \u003c\u003e z)" | |
} | |
} | |
] | |
} | |
], | |
"instances": [ | |
"String", | |
"Unit", | |
"Void", | |
"Array a", | |
"Semigroup s' =\u003e Semigroup (s -\u003e s')" | |
] | |
}, | |
"monoid": { | |
"name": "Monoid", | |
"parent": "semigroup", | |
"info": "Folding empty collection", | |
"members": [ | |
{ | |
"name": "mempty", | |
"def": "m", | |
"laws": [ | |
{ | |
"law": "associativity", | |
"example": { | |
"left": "mempty \u003c\u003e x", | |
"middle": "x \u003c\u003e mempty", | |
"right": "x forall x" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "power", | |
"def": "Monoid m =\u003e m -\u003e Int -\u003e m" | |
}, | |
{ | |
"name": "guard", | |
"def": "Monoid m =\u003e Boolean -\u003e m -\u003e m" | |
} | |
], | |
"instances": [ | |
"Unit", | |
"Ordering", | |
"Number", | |
"String", | |
"Array a", | |
"Monoid b =\u003e Monoid (a -\u003e b)" | |
] | |
}, | |
"eq": { | |
"name": "Eq", | |
"package": "Data", | |
"info": "Equality", | |
"members": [ | |
{ | |
"name": "eq", | |
"def": "a -\u003e a -\u003e Boolean", | |
"op": "==", | |
"laws": [ | |
{ | |
"law": "reflexivity", | |
"example": { | |
"left": "x == x", | |
"right": "true" | |
} | |
}, | |
{ | |
"law": "symmetry", | |
"example": { | |
"left": "x == y", | |
"right": "y == x" | |
} | |
}, | |
{ | |
"law": "transitivity", | |
"example": { | |
"fact": "(x == y) and (y == z)", | |
"conclusion": "y == x" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "notEq", | |
"op": "/=", | |
"def": "Eq a =\u003e a -\u003e a -\u003e Boolean" | |
} | |
], | |
"instances": [ | |
"Boolean", | |
"Int", | |
"Number", | |
"Char", | |
"String", | |
"Unit", | |
"Void", | |
"Eq a =\u003e Eq (Array a)" | |
] | |
}, | |
"ord": { | |
"name": "Ord", | |
"info": "Ordering", | |
"parent": "eq", | |
"members": [ | |
{ | |
"name": "compart", | |
"def": "a -\u003e a -\u003e Ordering", | |
"op": "==", | |
"laws": [ | |
{ | |
"law": "reflexivity", | |
"example": { | |
"fact": "a \u003c= a" | |
} | |
}, | |
{ | |
"law": "antisymmetry", | |
"example": { | |
"fact": "(a \u003c= b) and (b \u003c= a)", | |
"conclusion": "a = b" | |
} | |
}, | |
{ | |
"law": "transitivity", | |
"example": { | |
"fact": "(a \u003c= b) and (b \u003c= c)", | |
"conclusion": "a \u003c= c" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "lessThan", | |
"op": "\u003c", | |
"def": "Ord a =\u003e a -\u003e a -\u003e Boolean" | |
}, | |
{ | |
"name": "greaterThan", | |
"op": "\u003e", | |
"def": "Ord a =\u003e a -\u003e a -\u003e Boolean" | |
}, | |
{ | |
"name": "lessThanOrEq", | |
"op": "\u003c=", | |
"def": "Ord a =\u003e a -\u003e a -\u003e Boolean" | |
}, | |
{ | |
"name": "greaterThanOrEq", | |
"op": "\u003e=", | |
"def": "Ord a =\u003e a -\u003e a -\u003e Boolean" | |
}, | |
{ | |
"name": "min", | |
"def": "Ord a =\u003e a -\u003e a -\u003e a" | |
}, | |
{ | |
"name": "max", | |
"def": "Ord a =\u003e a -\u003e a -\u003e a" | |
}, | |
{ | |
"name": "clamp", | |
"def": "Ord a =\u003e a -\u003e a -\u003e a -\u003e a" | |
}, | |
{ | |
"name": "between", | |
"def": "Ord a =\u003e a -\u003e a -\u003e a -\u003e Boolean" | |
}, | |
{ | |
"name": "abs", | |
"def": "(Ord a, Ring a) =\u003e a -\u003e a" | |
}, | |
{ | |
"name": "signum", | |
"def": "(Ord a, Ring a) =\u003e a -\u003e a" | |
}, | |
{ | |
"name": "comparing", | |
"def": "Ord b =\u003e (a -\u003e b) -\u003e (a -\u003e a -\u003e Ordering)" | |
} | |
] | |
}, | |
"bounded": { | |
"name": "Bounded", | |
"parent": "ord", | |
"info": "Have upper and lower boundary", | |
"package": "Data", | |
"laws": [ | |
{ | |
"name": "bounded", | |
"fact": "bottom \u003c= a \u003c= top" | |
} | |
], | |
"members": [ | |
{ | |
"name": "top", | |
"def": "a" | |
}, | |
{ | |
"name": "bottom", | |
"def": "a" | |
} | |
], | |
"instances": [ | |
"Boolean", | |
"Int", | |
"Char", | |
"Ordering", | |
"Unit" | |
] | |
}, | |
"ordering": { | |
"name": "Ordering", | |
"info": "Just to know the order", | |
"values": [ | |
"LT", | |
"GT", | |
"EQ" | |
], | |
"members": [ | |
{ | |
"name": "invert", | |
"def": "Ordering -\u003e Ordering" | |
} | |
], | |
"instances": [ | |
"Eq Ordering", | |
"Semigroup Ordering", | |
"Show Ordering" | |
] | |
}, | |
"show": { | |
"name": "Show", | |
"info": "Displaying values", | |
"package": "Data", | |
"members": [ | |
{ | |
"name": "show", | |
"def": "a -\u003e String" | |
} | |
], | |
"instances": [ | |
"Show Boolean", | |
"Show Int", | |
"Show Number", | |
"Show Char", | |
"Show String", | |
"Show a =\u003e Show (Array a)" | |
] | |
}, | |
"heytingAlgebra": { | |
"name": "HeytingAlgebra", | |
"info": "Bounded lattices, boolean starters", | |
"members": [ | |
{ | |
"name": "ff", | |
"def": "a" | |
}, | |
{ | |
"name": "tt", | |
"def": "a" | |
}, | |
{ | |
"name": "implies", | |
"def": "a -\u003e a -\u003e a" | |
}, | |
{ | |
"name": "conj", | |
"def": "a -\u003e a -\u003e a", | |
"op": "\u0026\u0026" | |
}, | |
{ | |
"name": "disj", | |
"def": "a -\u003e a -\u003e a", | |
"op": "||" | |
}, | |
{ | |
"name": "not", | |
"def": "a" | |
} | |
], | |
"laws": [ | |
{ | |
"law": "associativity", | |
"examples": [ | |
{ | |
"left": "a || (b || c)", | |
"right": "(a || b) || c" | |
}, | |
{ | |
"left": "a \u0026\u0026 (b \u0026\u0026 c)", | |
"right": "(a \u0026\u0026 b) \u0026\u0026 c" | |
} | |
] | |
}, | |
{ | |
"law": "commutativity", | |
"examples": [ | |
{ | |
"left": "a || b", | |
"right": "b || a" | |
}, | |
{ | |
"left": "a \u0026\u0026 b", | |
"right": "b \u0026\u0026 a" | |
} | |
] | |
}, | |
{ | |
"law": "absorption", | |
"examples": [ | |
{ | |
"left": "a || (a \u0026\u0026 b)", | |
"right": "a" | |
}, | |
{ | |
"left": "a \u0026\u0026 a", | |
"right": "a" | |
} | |
] | |
}, | |
{ | |
"law": "idempotent", | |
"examples": [ | |
{ | |
"left": "a || a", | |
"right": "a" | |
}, | |
{ | |
"left": "a \u0026\u0026 (a || b)", | |
"right": "a" | |
} | |
] | |
}, | |
{ | |
"law": "identity", | |
"examples": [ | |
{ | |
"left": "a || ff", | |
"right": "a" | |
}, | |
{ | |
"left": "a \u0026\u0026 tt", | |
"right": "a" | |
} | |
] | |
}, | |
{ | |
"law": "implication", | |
"examples": [ | |
{ | |
"left": "a `implies` a", | |
"right": "tt" | |
}, | |
{ | |
"left": "a \u0026\u0026 (a `implies` b)", | |
"right": "a \u0026\u0026 b" | |
}, | |
{ | |
"left": "b \u0026\u0026 (a `implies` b)", | |
"right": "b" | |
}, | |
{ | |
"left": "a `implies` (b \u0026\u0026 c)", | |
"right": "(a `implies` b) \u0026\u0026 (a `implies` c)" | |
} | |
] | |
}, | |
{ | |
"law": "complemented", | |
"example": { | |
"left": "not a", | |
"right": "a `implies` ff" | |
} | |
} | |
], | |
"instances": [ | |
"Boolean", | |
"Unit", | |
"(a -\u003e b)" | |
] | |
}, | |
"booleanAlgebra": { | |
"name": "BooleanAlgebra", | |
"info": "Behave like boolean", | |
"parent": "heytingAlgebra", | |
"laws": [ | |
{ | |
"name": "excluded middle", | |
"def": "a || not a == tt" | |
} | |
], | |
"instances": [ | |
"Boolean", | |
"Unit", | |
"BooleanAlgebra b =\u003e BooleanAlgebra (a -\u003e b)" | |
] | |
}, | |
"boolean": { | |
"name": "Boolean", | |
"info": "Helpers for boolean types", | |
"members": [ | |
{ | |
"name": "otherwise", | |
"def": "Boolean" | |
} | |
] | |
}, | |
"divisionRing": { | |
"name": "DivisionRing", | |
"parent": "ring", | |
"info": "Non-zero rings in which every non-zero element has a multiplicative inverse / skew fields", | |
"members": [ | |
{ | |
"name": "recip", | |
"def": "a -\u003e a", | |
"laws": [ | |
{ | |
"law": "Non-zero Ring", | |
"fact": "one /= zero" | |
}, | |
{ | |
"law": "Non-zero multplicative inverse", | |
"left": "recip a * a", | |
"middle": "a * recip a", | |
"right": "one forall a /= 0" | |
} | |
] | |
}, | |
{ | |
"name": "leftDiv", | |
"def": "DivisionRing a =\u003e a -\u003e a -\u003e a" | |
}, | |
{ | |
"name": "rightDiv", | |
"def": "DivisionRing a =\u003e a -\u003e a -\u003e a" | |
} | |
], | |
"instances": [ | |
"Number" | |
] | |
}, | |
"semiring": { | |
"name": "Semiring", | |
"info": "Sum and Multiply (a.k.a. extended Monoid)", | |
"members": [ | |
{ | |
"name": "add", | |
"def": "a -\u003e a -\u003e a", | |
"op": "+" | |
}, | |
{ | |
"name": "zero", | |
"def": "a" | |
}, | |
{ | |
"name": "mul", | |
"def": "a -\u003e a -\u003e a", | |
"op": "*" | |
}, | |
{ | |
"name": "one", | |
"def": "a" | |
} | |
], | |
"laws": [ | |
{ | |
"law": "associativity", | |
"left": "(a + b) + c", | |
"right": "a + (b + c)" | |
}, | |
{ | |
"law": "identity", | |
"left": "zero + a", | |
"middle": "a + zero", | |
"right": "a" | |
}, | |
{ | |
"law": "commutative", | |
"left": "a + b", | |
"right": "b + a" | |
}, | |
{ | |
"law": "associativity", | |
"left": "(a + b) * c", | |
"right": "a * (b * c)" | |
}, | |
{ | |
"law": "identity", | |
"left": "one * a", | |
"middle": "a * one", | |
"right": "a" | |
}, | |
{ | |
"law": "left distributivity", | |
"left": "a * (b + c)", | |
"right": "(a * b) + (a * c)" | |
}, | |
{ | |
"law": "right distributivity", | |
"left": "a + (b * c)", | |
"right": "(a * c) + (b * c)" | |
}, | |
{ | |
"law": "annihilation", | |
"left": "zero * a", | |
"middle": "a * zero", | |
"right": "zero" | |
} | |
], | |
"instances": [ | |
"Int", | |
"Number", | |
"Semiring b =\u003e Semiring (a -\u003e b)" | |
] | |
}, | |
"ring": { | |
"parent": "semiring", | |
"name": "Ring", | |
"info": "Subtraction", | |
"members": [ | |
{ | |
"name": "sub", | |
"def": "a -\u003e a -\u003e a", | |
"op": "-", | |
"laws": [ | |
{ | |
"law": "Additive inverse", | |
"left": "a - a", | |
"middle": "zero - a", | |
"right": "zero" | |
} | |
] | |
}, | |
{ | |
"name": "negate", | |
"def": "Ring a =\u003e a -\u003e a" | |
} | |
], | |
"instances": [ | |
"Int", | |
"Number", | |
"Unit", | |
"Ring b =\u003e Ring (a -\u003e b)" | |
] | |
}, | |
"commutativeRing": { | |
"name": "CommutativeRing", | |
"info": "Multiplication behaves commutatively", | |
"parent": "ring", | |
"laws": [ | |
{ | |
"law": "commutative", | |
"left": "a * b", | |
"right": "b * a" | |
} | |
], | |
"instances": [ | |
"Int", | |
"Number", | |
"Unit", | |
"CommutativeRing b =\u003e CommutativeRing (a -\u003e b)" | |
] | |
}, | |
"euclidianRing": { | |
"name": "EuclidianRing", | |
"info": "Divide and Conquer", | |
"parent": "commutativeRing", | |
"members": [ | |
{ | |
"name": "degree", | |
"def": "a -\u003e Int" | |
}, | |
{ | |
"name": "div", | |
"def": "a -\u003e a -\u003e a", | |
"op": "/" | |
}, | |
{ | |
"name": "mode", | |
"def": "a -\u003e a -\u003e a" | |
}, | |
{ | |
"name": "gcd", | |
"def": "Eq a =\u003e EuclideanRing a =\u003e a -\u003e a -\u003e a" | |
}, | |
{ | |
"name": "lcm", | |
"def": "Eq a =\u003e EuclideanRing a =\u003e a -\u003e a -\u003e a" | |
} | |
], | |
"laws": [ | |
{ | |
"law": "integral domain", | |
"fact": "(a /= 0) and (b /= 0)", | |
"conclusion": "a * b /= 0" | |
}, | |
{ | |
"law": "multiplicative Euclidean function", | |
"right": "a", | |
"left": "(a / b) * b + (a `mod` b)", | |
"conditions": [ | |
"degree a \u003e 0", | |
"degree a \u003c= degree (a * b)" | |
] | |
} | |
], | |
"instances": [ | |
"Int", | |
"Number" | |
] | |
}, | |
"field": { | |
"info": "Commutative fields", | |
"parent": "euclidianRing", | |
"laws": [ | |
{ | |
"law": "non-zero multiplicative inverse", | |
"right": "a `mod` b", | |
"left": "0" | |
} | |
], | |
"instances": [ | |
"Int", | |
"Number" | |
] | |
}, | |
"endo": { | |
"name": "Endo", | |
"info": "By itself", | |
"package": "Data.Monoid", | |
"statements": [ | |
{ | |
"left": "Endo f \u003c\u003e Endo g", | |
"right": "Endo (f \u003c\u003c\u003c g)" | |
}, | |
{ | |
"left": "mempty :: Endo _", | |
"right": "Endo id" | |
} | |
], | |
"instances": [ | |
"Newtype (Endo a) _", | |
"Invariant Endo", | |
"Semigroup (Endo a)", | |
"Monoid (Endo a)" | |
] | |
}, | |
"dual": { | |
"name": "Dual", | |
"info": "Monoid under dualism", | |
"package": "Data.Monoid", | |
"statements": [ | |
{ | |
"left": "Dual x \u003c\u003e Dual y", | |
"right": "Dual (y \u003c\u003e x)" | |
}, | |
{ | |
"left": "mempty :: Dual _", | |
"right": "Dual mempty" | |
} | |
], | |
"instances": [ | |
"Newtype (Dual a) _", | |
"Eq a =\u003e Eq (Dual a)", | |
"Ord a =\u003e Ord (Dual a)", | |
"Bounded a =\u003e Bounded (Dual a)", | |
"Functor Dual", | |
"Invariant Dual", | |
"Apply Dual", | |
"Applicative Dual", | |
"Bind Dual", | |
"Monad Dual", | |
"Extend Dual", | |
"Comonad Dual", | |
"Show a =\u003e Show (Dual a)", | |
"Semigroup a =\u003e Semigroup (Dual a)", | |
"Monoid a =\u003e Monoid (Dual a)" | |
] | |
}, | |
"additive": { | |
"name": "Additive", | |
"info": "May be added to something", | |
"package": "Data.Monoid", | |
"statements": [ | |
{ | |
"left": "Additive x \u003c\u003e Additive y", | |
"right": "Additive (x + y)" | |
}, | |
{ | |
"left": "mempty :: Additive _", | |
"right": "Additive zero" | |
} | |
], | |
"instances": [ | |
"Newtype (Additive a) _", | |
"Eq a =\u003e Eq (Additive a)", | |
"Ord a =\u003e Ord (Additive a)", | |
"Bounded a =\u003e Bounded (Additive a)", | |
"Functor Additive", | |
"Invariant Additive", | |
"Apply Additive", | |
"Applicative Additive", | |
"Bind Additive", | |
"Monad Additive", | |
"Extend Additive", | |
"Comonad Additive", | |
"Show a =\u003e Show (Additive a)", | |
"Semiring a =\u003e Semigroup (Additive a)", | |
"Semiring a =\u003e Monoid (Additive a)" | |
] | |
}, | |
"multiplicative": { | |
"name": "Multiplicative", | |
"info": "May be multiplied on something", | |
"package": "Data.Monoid", | |
"statements": [ | |
{ | |
"left": "Multiplicative x \u003c\u003e Multiplicative y", | |
"right": "Multiplicative (x * y)" | |
}, | |
{ | |
"left": "mempty :: Multiplicative _", | |
"right": "Multiplicative one" | |
} | |
], | |
"instances": [ | |
"Newtype (Multiplicative a) _", | |
"Eq a =\u003e Eq (Multiplicative a)", | |
"Ord a =\u003e Ord (Multiplicative a)", | |
"Bounded a =\u003e Bounded (Multiplicative a)", | |
"Functor Multiplicative", | |
"Invariant Multiplicative", | |
"Apply Multiplicative", | |
"Applicative Multiplicative", | |
"Bind Multiplicative", | |
"Monad Multiplicative", | |
"Extend Multiplicative", | |
"Comonad Multiplicative", | |
"Show a =\u003e Show (Multiplicative a)", | |
"Semiring a =\u003e Semigroup (Multiplicative a)", | |
"Semiring a =\u003e Monoid (Multiplicative a)" | |
] | |
}, | |
"conj": { | |
"name": "Multiplicative", | |
"info": "Monoid under conjunction", | |
"package": "Data.Monoid", | |
"statements": [ | |
{ | |
"left": "Conj x \u003c\u003e Conj y", | |
"right": "Conj (x \u0026\u0026 y)" | |
}, | |
{ | |
"left": "mempty :: Conj _", | |
"right": "Conj top" | |
} | |
], | |
"instances": [ | |
"Newtype (Conj a) _", | |
"Eq a =\u003e Eq (Conj a)", | |
"Ord a =\u003e Ord (Conj a)", | |
"Bounded a =\u003e Bounded (Conj a)", | |
"Functor Conj", | |
"Invariant Conj", | |
"Apply Conj", | |
"Applicative Conj", | |
"Bind Conj", | |
"Monad Conj", | |
"Extend Conj", | |
"Comonad Conj", | |
"Show a =\u003e Show (Conj a)", | |
"HeytingAlgebra a =\u003e Semigroup (Conj a)", | |
"HeytingAlgebra a =\u003e Monoid (Conj a)", | |
"HeytingAlgebra a =\u003e Semiring (Conj a)" | |
] | |
}, | |
"disj": { | |
"name": "Disj", | |
"info": "Monoid under disjunction", | |
"package": "Data.Monoid", | |
"statements": [ | |
{ | |
"left": "Conj x \u003c\u003e Conj y", | |
"right": "Disj (x || y)" | |
}, | |
{ | |
"left": "mempty :: Disj _", | |
"right": "Disj bottom" | |
} | |
], | |
"instances": [ | |
"Newtype (Disj a) _", | |
"Eq a =\u003e Eq (Disj a)", | |
"Ord a =\u003e Ord (Disj a)", | |
"Bounded a =\u003e Bounded (Disj a)", | |
"Functor Disj", | |
"Invariant Disj", | |
"Apply Disj", | |
"Applicative Disj", | |
"Bind Disj", | |
"Monad Disj", | |
"Extend Disj", | |
"Comonad Disj", | |
"Show a =\u003e Show (Disj a)", | |
"HeytingAlgebra a =\u003e Semigroup (Disj a)", | |
"HeytingAlgebra a =\u003e Monoid (Disj a)", | |
"HeytingAlgebra a =\u003e Semiring (Disj a)" | |
] | |
}, | |
"alternate": { | |
"name": "Alternate", | |
"info": "Monoid and Semigroup instances corresponding to Plus and Alt for f", | |
"package": "Data.Monoid", | |
"statements": [ | |
{ | |
"left": "Alternate fx \u003c\u003e Alternate fy", | |
"right": "Alternate (fx \u003c|\u003e fy)" | |
}, | |
{ | |
"left": "mempty :: Alternate _", | |
"right": "Alternate empty" | |
} | |
], | |
"instances": [ | |
"Newtype (Alternate f a) _", | |
"Eq a =\u003e Eq (Alternate f)", | |
"Ord a =\u003e Ord (Alternate a)", | |
"Bounded a =\u003e Bounded (Alternate a)", | |
"Functor f =\u003e Functor Alternate", | |
"Invariant f =\u003e Invariant (Alternate f)", | |
"Apply f =\u003e Apply Alternate", | |
"Applicative f =\u003e Applicative Alternate", | |
"Bind f =\u003e Bind Alternate", | |
"Monad Additive", | |
"Extend Additive", | |
"Comonad Additive", | |
"Show (Alternate f a)", | |
"Semigroup (Alternate f a)", | |
"Monoid (Alternate f a)" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment