@@ -42,362 +42,3 @@ public %assert_total -- reduces at compile time, use with extreme care!
42really_believe_me : a -> b
42really_believe_me : a -> b
43really_believe_me x = prim__believe_me _ _ x
43really_believe_me x = prim__believe_me _ _ x
45−-- ---------------------------------------------------------------- [ Builtins ]
51−-- | Identity function.
55−-- | Manually assign a type to an expression.
56−the : (a : Type) -> a -> a
59−-- | Constant function.
63−-- | Return the first element of a pair.
67−-- | Return the second element of a pair.
73−-- | Function composition
74−(.) : (b -> c) -> (a -> b) -> a -> c
77−-- | Takes in the first two arguments in reverse order.
78−flip : (a -> b -> c) -> b -> a -> c
83−-- | Function application.
84−($) : (a -> b) -> a -> b
87−cong : {f : t -> u} -> (a = b) -> f a = f b
90−data Dec : Type -> Type where
91− Yes : {A : Type} -> A -> Dec A
92− No : {A : Type} -> (A -> _|_) -> Dec A
94−-- | Boolean Data Type
95−data Bool = False | True
97−-- | Boolean elimination
98−boolElim : Bool -> |(t : a) -> |(f : a) -> a
100−boolElim False t e = e
102−-- | Defines a predicate on Bool which guarantees that the value is true.
103−data so : Bool -> Type where oh : so True
105−-- Syntaxtic sugar for boolean elimination.
106−syntax if [test] then [t] else [e] = boolElim test t e
107−syntax [test] "?" [t] ":" [e] = if test then t else e
109−-- Boolean Operator Precedence
113−(||) : Bool -> Bool -> Bool
118−(&&) : Bool -> Bool -> Bool
127−-- Numerical Operator Precedence
129−infixl 6 <, <=, >, >=
134−-- ------------------------------------------------------- [ Numeric Operators ]
135−intToBool : Int -> Bool
139−boolOp : (a -> a -> Int) -> a -> a -> Bool
140−boolOp op x y = intToBool (op x y)
142−-- | The Eq class defines inequality and equality.
144− (==) : a -> a -> Bool
145− (/=) : a -> a -> Bool
147− x /= y = not (x == y)
148− x == y = not (x /= y)
150−instance Eq Int where
151− (==) = boolOp prim__eqInt
153−instance Eq Integer where
154− (==) = boolOp prim__eqBigInt
156−instance Eq Float where
157− (==) = boolOp prim__eqFloat
159−instance Eq Char where
160− (==) = boolOp prim__eqChar
162−instance Eq String where
163− (==) = boolOp prim__eqString
165−instance Eq Bool where
167− True == False = False
168− False == True = False
169− False == False = True
171−instance (Eq a, Eq b) => Eq (a, b) where
172− (==) (a, c) (b, d) = (a == b) && (c == d)
175−data Ordering = LT | EQ | GT
177−instance Eq Ordering where
183−-- | The Ord class defines comparison operations on ordered data types.
184−class Eq a => Ord a where
185− compare : a -> a -> Ordering
187− (<) : a -> a -> Bool
188− (<) x y with (compare x y)
192− (>) : a -> a -> Bool
193− (>) x y with (compare x y)
197− (<=) : a -> a -> Bool
198− (<=) x y = x < y || x == y
200− (>=) : a -> a -> Bool
201− (>=) x y = x > y || x == y
204− max x y = if (x > y) then x else y
207− min x y = if (x < y) then x else y
210−instance Ord Int where
211− compare x y = if (x == y) then EQ else
212− if (boolOp prim__sltInt x y) then LT else
216−instance Ord Integer where
217− compare x y = if (x == y) then EQ else
218− if (boolOp prim__sltBigInt x y) then LT else
222−instance Ord Float where
223− compare x y = if (x == y) then EQ else
224− if (boolOp prim__sltFloat x y) then LT else
228−instance Ord Char where
229− compare x y = if (x == y) then EQ else
230− if (boolOp prim__sltChar x y) then LT else
234−instance Ord String where
235− compare x y = if (x == y) then EQ else
236− if (boolOp prim__ltString x y) then LT else
240−instance (Ord a, Ord b) => Ord (a, b) where
241− compare (xl, xr) (yl, yr) =
246−-- | The Num class defines basic numerical arithmetic.
253− -- | Conversion from Integer.
254− fromInteger : Integer -> a
256−instance Num Integer where
257− (+) = prim__addBigInt
258− (-) = prim__subBigInt
259− (*) = prim__mulBigInt
261− abs x = if x < 0 then -x else x
264−instance Num Int where
269− fromInteger = prim__truncBigInt_Int
270− abs x = if x < (prim__truncBigInt_Int 0) then -x else x
273−instance Num Float where
274− (+) = prim__addFloat
275− (-) = prim__subFloat
276− (*) = prim__mulFloat
278− abs x = if x < (prim__toFloatBigInt 0) then -x else x
279− fromInteger = prim__toFloatBigInt
281−instance Num Bits8 where
286− fromInteger = prim__truncBigInt_B8
288−instance Num Bits16 where
293− fromInteger = prim__truncBigInt_B16
295−instance Num Bits32 where
300− fromInteger = prim__truncBigInt_B32
302−instance Num Bits64 where
307− fromInteger = prim__truncBigInt_B64
309−instance Eq Bits8 where
310− x == y = intToBool (prim__eqB8 x y)
312−instance Eq Bits16 where
313− x == y = intToBool (prim__eqB16 x y)
315−instance Eq Bits32 where
316− x == y = intToBool (prim__eqB32 x y)
318−instance Eq Bits64 where
319− x == y = intToBool (prim__eqB64 x y)
321−instance Ord Bits8 where
322− (<) = boolOp prim__ltB8
323− (>) = boolOp prim__gtB8
324− (<=) = boolOp prim__lteB8
325− (>=) = boolOp prim__gteB8
326− compare l r = if l < r then LT
327− else if l > r then GT
330−instance Ord Bits16 where
331− (<) = boolOp prim__ltB16
332− (>) = boolOp prim__gtB16
333− (<=) = boolOp prim__lteB16
334− (>=) = boolOp prim__gteB16
335− compare l r = if l < r then LT
336− else if l > r then GT
339−instance Ord Bits32 where
340− (<) = boolOp prim__ltB32
341− (>) = boolOp prim__gtB32
342− (<=) = boolOp prim__lteB32
343− (>=) = boolOp prim__gteB32
344− compare l r = if l < r then LT
345− else if l > r then GT
348−instance Ord Bits64 where
349− (<) = boolOp prim__ltB64
350− (>) = boolOp prim__gtB64
351− (<=) = boolOp prim__lteB64
352− (>=) = boolOp prim__gteB64
353− compare l r = if l < r then LT
354− else if l > r then GT
357−-- | Integer division.
359−div : Integer -> Integer -> Integer
360−div = prim__sdivBigInt
362−-- | Integer modulus.
364−mod : Integer -> Integer -> Integer
365−mod = prim__sremBigInt
367−-- | Fractional division of two Floats.
368−(/) : Float -> Float -> Float
371−-- -------------------------------------------------------- [ String Operators ]
372−-- | Appends two strings together.
373−(++) : String -> String -> String
376−-- | Returns the first character in the specified string.
378−strHead : String -> Char
379−strHead = prim__strHead
381−-- | Returns the characters specified after the head of the string.
383−strTail : String -> String
384−strTail = prim__strTail
386−-- | Adds a character to the from of the specified string.
387−strCons : Char -> String -> String
388−strCons = prim__strCons
390−-- | Returns the nth character (starting from 0) of the specified string.
392−strIndex : String -> Int -> Char
393−strIndex = prim__strIndex
395−-- | Reverses the elements within a String.
396−reverse : String -> String
397−reverse = prim__strRev