File tree 4 files changed +11
-0
lines changed
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
18
18
19
19
instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
20
20
instance 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
20
20
instance commutativeRingInt :: CommutativeRing Int
21
21
instance commutativeRingNumber :: CommutativeRing Number
22
22
instance 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
27
27
instance ringUnit :: Ring Unit where
28
28
sub _ _ = unit
29
29
30
+ instance ringFn :: Ring b => Ring (a -> b ) where
31
+ sub f g x = f x - g x
32
+
30
33
-- | `negate x` can be used as a shorthand for `zero - x`.
31
34
negate :: forall a . Ring a => a -> a
32
35
negate a = zero - a
Original file line number Diff line number Diff line change @@ -44,6 +44,12 @@ instance semiringNumber :: Semiring Number where
44
44
mul = numMul
45
45
one = 1.0
46
46
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
+
47
53
instance semiringUnit :: Semiring Unit where
48
54
add _ _ = unit
49
55
zero = unit
You can’t perform that action at this time.
0 commit comments