_+_ works with an Add typeclass now.
- add test case - fix some issues with eval - filter out non-candidates for auto search
This commit is contained in:
38
tests/black/Auto2.newt
Normal file
38
tests/black/Auto2.newt
Normal file
@@ -0,0 +1,38 @@
|
||||
module Auto2
|
||||
|
||||
ptype World
|
||||
pfunc log : {A : U} -> A -> World := "(_, a) => console.log(a)"
|
||||
|
||||
ptype Int
|
||||
pfunc i_plus : Int -> Int -> Int := "(x,y) => x + y"
|
||||
|
||||
data Nat : U where
|
||||
Z : Nat
|
||||
S : Nat -> Nat
|
||||
|
||||
plus : Nat -> Nat -> Nat
|
||||
plus Z x = x
|
||||
plus (S k) x = S (plus k x)
|
||||
|
||||
-- a type class
|
||||
data Add : U -> U where
|
||||
MkAdd : {A : U} -> (A -> A -> A) -> Add A
|
||||
|
||||
infixl 8 _+_
|
||||
_+_ : {A : U} -> {{myadd : Add A}} -> A -> A -> A
|
||||
_+_ {_} {{MkAdd adder}} x y = adder x y
|
||||
|
||||
-- Two instances
|
||||
addInt : Add Int
|
||||
addInt = MkAdd i_plus
|
||||
|
||||
addNat : Add Nat
|
||||
addNat = MkAdd plus
|
||||
|
||||
-- sequencing hack
|
||||
infixl 2 _>>_
|
||||
_>>_ : {a b : U} -> a -> b -> b
|
||||
a >> b = b
|
||||
|
||||
main : World -> World
|
||||
main _ = log (40 + 2) >> log (Z + Z)
|
||||
Reference in New Issue
Block a user