additional syntactic sugar

- allow multiple names in infix, typesig, and dcon defs
- align fixities with Idris
This commit is contained in:
2024-10-23 21:41:36 -07:00
parent 8c8cdf4f7f
commit 8fe9613c02
8 changed files with 40 additions and 45 deletions

View File

@@ -51,7 +51,7 @@ part1 text digits =
let nums = map combine $ map digits lines in
foldl _+_ 0 nums
infixl 3 _>>_
infixl 1 _>>_
_>>_ : {A B : U} -> A -> B -> B
a >> b = b

View File

@@ -12,7 +12,7 @@ data Game : U where
-- Add, Sub, Mul, Neg
-- NB this is not lazy!
infixl 2 _&&_
infixl 5 _&&_
_&&_ : Bool -> Bool -> Bool
a && b = case a of
@@ -68,7 +68,7 @@ parseGame line =
_ => Left "No Game"
_ => Left $ "No colon in " ++ line
infixl 3 _>>_
infixl 1 _>>_
_>>_ : {A B : U} -> A -> B -> B
a >> b = b

View File

@@ -21,7 +21,7 @@ data Either : U -> U -> U where
Right : {a b : U} -> b -> Either a b
infixr 4 _::_
infixr 7 _::_
data List : U -> U where
Nil : {a : U} -> List a
_::_ : {a : U} -> a -> List a -> List a
@@ -41,11 +41,12 @@ length : {a : U} -> List a -> Nat
length Nil = Z
length (x :: xs) = S (length xs)
infixr 2 _,_
infixr 0 _,_
data Pair : U -> U -> U where
_,_ : {a b : U} -> a -> b -> Pair a b
-- Idris says it special cases to deal with unification issues
infixr 0 _$_
_$_ : {a b : U} -> (a -> b) -> a -> b
@@ -104,13 +105,10 @@ pfunc _+_ : Int -> Int -> Int := "(x,y) => x + y"
pfunc _-_ : Int -> Int -> Int := "(x,y) => x - y"
pfunc _*_ : Int -> Int -> Int := "(x,y) => x * y"
pfunc _/_ : Int -> Int -> Int := "(x,y) => x / y"
infix 3 _<_
infix 3 _<=_
infixl 4 _-_
infixl 4 _+_
infixl 5 _*_
infixl 5 _/_
infix 6 _<_ _<=_
infixl 8 _+_ _-_
infixl 9 _*_ _/_
-- Ideally we'd have newt write the arrows for us to keep things correct
-- We'd still have difficulty with callbacks...
@@ -134,7 +132,7 @@ pfunc slen : String -> Int := "s => s.length"
pfunc sindex : String -> Int -> Char := "(s,i) => s[i]"
infixl 4 _++_
infixl 7 _++_
pfunc _++_ : String -> String -> String := "(a,b) => a + b"
@@ -159,6 +157,6 @@ map f Nil = Nil
map f (x :: xs) = f x :: map f xs
infixl 7 _._
infixl 9 _._
_._ : {A B C : U} -> (B -> C) -> (A -> B) -> A -> C
(f . g) x = f ( g x)