File tree Expand file tree Collapse file tree 4 files changed +11
-0
lines changed Expand file tree Collapse file tree 4 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,4 @@ class HeytingAlgebra a <= BooleanAlgebra a
1818
1919instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
2020instance booleanAlgebraUnit :: BooleanAlgebra Unit
21+ instance booleanAlgebraFn :: BooleanAlgebra b => BooleanAlgebra (a -> b )
Original file line number Diff line number Diff line change @@ -20,3 +20,4 @@ class Ring a <= CommutativeRing a
2020instance commutativeRingInt :: CommutativeRing Int
2121instance commutativeRingNumber :: CommutativeRing Number
2222instance commutativeRingUnit :: CommutativeRing Unit
23+ instance commutativeRingFn :: CommutativeRing b => CommutativeRing (a -> b )
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ instance ringNumber :: Ring Number where
2727instance ringUnit :: Ring Unit where
2828 sub _ _ = unit
2929
30+ instance ringFn :: Ring b => Ring (a -> b ) where
31+ sub f g x = f x - g x
32+
3033-- | `negate x` can be used as a shorthand for `zero - x`.
3134negate :: forall a . Ring a => a -> a
3235negate a = zero - a
Original file line number Diff line number Diff line change @@ -44,6 +44,12 @@ instance semiringNumber :: Semiring Number where
4444 mul = numMul
4545 one = 1.0
4646
47+ instance semiringFn :: Semiring b => Semiring (a -> b ) where
48+ add f g x = f x + g x
49+ zero = \_ -> zero
50+ mul f g x = f x * g x
51+ one = \_ -> one
52+
4753instance semiringUnit :: Semiring Unit where
4854 add _ _ = unit
4955 zero = unit
You can’t perform that action at this time.
0 commit comments