on master help sign in
Renamed Prelude.Classes to Prelude.Interfaces
commit74926fffabb951d6d46d4a75574a04faa4520e76 authorJan de Muijnck-Hughes <jfdm@st-andrews.ac.uk> dateTue 26 Jan 2016, 21:56 (11 years ago) parentf7a9c28
20 files changed+107−126
libs/prelude/Decidable/Equality.idr+2−5 libs/prelude/Prelude.idr+4−5 libs/prelude/Prelude/Applicative.idr+1−1 libs/prelude/Prelude/Bits.idr+1−1 libs/prelude/Prelude/Chars.idr+1−3 libs/prelude/Prelude/Doubles.idr+3−5 libs/prelude/Prelude/Either.idr+1−1 libs/prelude/Prelude/File.idr+5−5 libs/prelude/Prelude/Foldable.idr+1−2 libs/prelude/Prelude/Interactive.idr+17−18 libs/prelude/Prelude/Classes.idr → libs/prelude/Prelude/Interfaces.idr+9−11 libs/prelude/Prelude/List.idr+4−5 libs/prelude/Prelude/Maybe.idr+1−1 libs/prelude/Prelude/Nat.idr+17−18 libs/prelude/Prelude/Show.idr+1−2 libs/prelude/Prelude/Strings.idr+2−3 libs/prelude/prelude.ipkg+1−2 src/Idris/ProofSearch.hs+31−33 test/interactive010/expected+3−3 test/syntax001/expected+2−2
libs/prelude/Decidable/Equality.idr+2−5
@@ -3,7 +3,7 @@ module Decidable.Equality
33import Builtins
44import Prelude.Basics
55import Prelude.Bool
6−import Prelude.Classes
6+import Prelude.Interfaces
77import Prelude.Either
88import Prelude.List
99import Prelude.Nat
@@ -141,7 +141,7 @@ implementation DecEq a => DecEq (List a) where
141141 decEq [] (x :: xs) = No (negEqSym lemma_val_not_nil)
142142 decEq (x :: xs) (y :: ys) with (decEq x y)
143143 decEq (x :: xs) (x :: ys) | Yes Refl with (decEq xs ys)
144− decEq (x :: xs) (x :: xs) | (Yes Refl) | (Yes Refl) = Yes Refl
144+ decEq (x :: xs) (x :: xs) | (Yes Refl) | (Yes Refl) = Yes Refl
145145 decEq (x :: xs) (x :: ys) | (Yes Refl) | (No p) = No (\eq => lemma_x_eq_xs_neq Refl p eq)
146146 decEq (x :: xs) (y :: ys) | No p with (decEq xs ys)
147147 decEq (x :: xs) (y :: xs) | (No p) | (Yes Refl) = No (\eq => lemma_x_neq_xs_eq p Refl eq)
@@ -211,6 +211,3 @@ implementation DecEq ManagedPtr where
211211 where primitiveEq : x = y
212212 primitiveEq = believe_me (Refl {x})
213213 postulate primitiveNotEq : x = y -> Void
214−
215−
216−
libs/prelude/Prelude.idr+4−5
@@ -6,7 +6,7 @@ import public IO
66import public Prelude.Algebra
77import public Prelude.Basics
88import public Prelude.Bool
9−import public Prelude.Classes
9+import public Prelude.Interfaces
1010import public Prelude.Cast
1111import public Prelude.Nat
1212import public Prelude.List
@@ -210,7 +210,7 @@ Enum Int where
210210Enum Char where
211211 toNat c = toNat (ord c)
212212 fromNat n = chr (fromNat n)
213−
213+
214214 pred c = fromNat (pred (toNat c))
215215
216216syntax "[" [start] ".." [end] "]"
@@ -264,12 +264,12 @@ while t b = do v <- t
264264------- Some error rewriting
265265
266266%language ErrorReflection
267−
267+
268268private
269269cast_part : TT -> ErrorReportPart
270270cast_part (P Bound n t) = TextPart "unknown type"
271271cast_part x = TermPart x
272−
272+
273273%error_handler
274274cast_error : Err -> Maybe (List ErrorReportPart)
275275cast_error (CantResolve `(Cast ~x ~y))
@@ -284,4 +284,3 @@ num_error : Err -> Maybe (List ErrorReportPart)
284284num_error (CantResolve `(Num ~x))
285285 = Just [TermPart x, TextPart "is not a numeric type"]
286286num_error _ = Nothing
287−
libs/prelude/Prelude/Applicative.idr+1−1
@@ -4,7 +4,7 @@ import Builtins
44
55import Prelude.Basics
66import Prelude.Bool
7−import Prelude.Classes
7+import Prelude.Interfaces
88import Prelude.Foldable
99import Prelude.Functor
1010
libs/prelude/Prelude/Bits.idr+1−1
@@ -6,7 +6,7 @@ import Prelude.Basics
66import Prelude.Bool
77import Prelude.Cast
88import Prelude.Chars
9−import Prelude.Classes
9+import Prelude.Interfaces
1010import Prelude.Foldable
1111import Prelude.Nat
1212import Prelude.List
libs/prelude/Prelude/Chars.idr+1−3
@@ -2,7 +2,7 @@ module Prelude.Chars
22-- Functions operating over Chars
33
44import Prelude.Bool
5−import Prelude.Classes
5+import Prelude.Interfaces
66import Prelude.List
77import Prelude.Cast
88import Builtins
@@ -74,5 +74,3 @@ isHexDigit x = elem (toUpper x) hexChars where
7474||| Returns true if the character is an octal digit.
7575isOctDigit : Char -> Bool
7676isOctDigit x = (x >= '0' && x <= '7')
77−
78−
libs/prelude/Prelude/Doubles.idr+3−5
@@ -1,7 +1,7 @@
1−module Prelude.Doubles
1+module Prelude.Doubles
22
33import Builtins
4−import Prelude.Classes
4+import Prelude.Interfaces
55
66%access public
77%default total
@@ -10,7 +10,7 @@ import Prelude.Classes
1010%lib C "m"
1111
1212pi : Double
13−pi = 3.14159265358979323846
13+pi = 3.14159265358979323846
1414
1515euler : Double
1616euler = 2.7182818284590452354
@@ -59,5 +59,3 @@ floor x = prim__floatFloor x
5959
6060ceiling : Double -> Double
6161ceiling x = prim__floatCeil x
62−
63−
libs/prelude/Prelude/Either.idr+1−1
@@ -4,7 +4,7 @@ import Builtins
44
55import Prelude.Basics
66import Prelude.Bool
7−import Prelude.Classes
7+import Prelude.Interfaces
88import Prelude.Maybe
99import Prelude.List
1010
libs/prelude/Prelude/File.idr+5−5
@@ -9,7 +9,7 @@ import Prelude.Strings
99import Prelude.Cast
1010import Prelude.Bool
1111import Prelude.Basics
12−import Prelude.Classes
12+import Prelude.Interfaces
1313import Prelude.Either
1414import Prelude.Show
1515import IO
@@ -39,7 +39,7 @@ strError err = unsafePerformIO -- yeah, yeah...
3939 (foreign FFI_C "idris_showerror" (Int -> IO String) err)
4040
4141getFileError : IO FileError
42−getFileError = do MkRaw err <- foreign FFI_C "idris_mkFileError"
42+getFileError = do MkRaw err <- foreign FFI_C "idris_mkFileError"
4343 (Ptr -> IO (Raw FileError)) prim__vm
4444 return err
4545
@@ -154,7 +154,7 @@ do_fwrite : Ptr -> String -> IO (Either FileError ())
154154do_fwrite h s = do res <- prim_fwrite h s
155155 if (res /= 0)
156156 then do errno <- getErrno
157− if errno == 0
157+ if errno == 0
158158 then return (Left FileWriteError)
159159 else do err <- getFileError
160160 return (Left err)
@@ -193,7 +193,7 @@ fpoll (FHandle h) = do p <- foreign FFI_C "fpoll" (Ptr -> IO Int) h
193193 return (p > 0)
194194
195195||| Read the contents of a file into a string
196−partial -- might be reading something infinitely long like /dev/null ...
196+partial -- might be reading something infinitely long like /dev/null ...
197197covering
198198readFile : String -> IO (Either FileError String)
199199readFile fn = do Right h <- openFile fn Read
@@ -212,7 +212,7 @@ readFile fn = do Right h <- openFile fn Read
212212 else return (Right contents)
213213
214214||| Write a string to a file
215−writeFile : (filepath : String) -> (contents : String) ->
215+writeFile : (filepath : String) -> (contents : String) ->
216216 IO (Either FileError ())
217217writeFile fn contents = do
218218 Right h <- openFile fn Write | Left err => return (Left err)
libs/prelude/Prelude/Foldable.idr+1−2
@@ -3,7 +3,7 @@ module Prelude.Foldable
33import Builtins
44import Prelude.Bool
55import Prelude.Basics
6−import Prelude.Classes
6+import Prelude.Interfaces
77import Prelude.Algebra
88
99%access public
@@ -54,4 +54,3 @@ sum = foldr (+) 0
5454||| Multiply together all elements of a structure
5555product : (Foldable t, Num a) => t a -> a
5656product = foldr (*) 1
57−
libs/prelude/Prelude/Interactive.idr+17−18
@@ -1,5 +1,5 @@
11||| Various helper functions for creating simple interactive systems.
2−|||
2+|||
33||| These are mostly intended for helping with teaching, in that they will allow
44||| the easy creation of interactive programs without needing to teach IO
55||| or Effects first, but they also capture some common patterns of interactive
@@ -10,7 +10,7 @@ import Builtins
1010import Prelude.List
1111import Prelude.File
1212import Prelude.Bool
13−import Prelude.Classes
13+import Prelude.Interfaces
1414import Prelude.Strings
1515import Prelude.Chars
1616import Prelude.Show
@@ -115,19 +115,19 @@ getArgs = do n <- numArgs
115115||| @ onEOF the function to run on reaching end of file, returning a String
116116||| to output
117117partial
118−processHandle : File ->
118+processHandle : File ->
119119 (state : a) ->
120− (onRead : a -> String -> (String, a)) ->
121− (onEOF : a -> String) ->
120+ (onRead : a -> String -> (String, a)) ->
121+ (onEOF : a -> String) ->
122122 IO ()
123−processHandle h acc onRead onEOF
123+processHandle h acc onRead onEOF
124124 = if !(fEOF h)
125125 then putStr (onEOF acc)
126126 else do Right x <- fGetLine h
127127 | Left err => putStr (onEOF acc)
128128 let (out, acc') = onRead acc x
129129 putStr out
130− processHandle h acc' onRead onEOF
130+ processHandle h acc' onRead onEOF
131131
132132||| Process input from the standard input stream, while maintaining a state.
133133||| @ state the input state
@@ -136,34 +136,33 @@ processHandle h acc onRead onEOF
136136||| @ onEOI the function to run on reaching end of input, returning a String
137137||| to output
138138partial
139−processStdin : (state : a) ->
140− (onRead : a -> String -> (String, a)) ->
139+processStdin : (state : a) ->
140+ (onRead : a -> String -> (String, a)) ->
141141 (onEOI : a -> String) -> IO ()
142142processStdin = processHandle stdin
143143
144144||| A basic read-eval-print loop, maintaining a state
145145||| @ state the input state
146−||| @ prompt the prompt to show
146+||| @ prompt the prompt to show
147147||| @ onInput the function to run on reading input, returning a String to
148148||| output and a new state. Returns Nothing if the repl should exit
149149partial
150−replWith : (state : a) -> (prompt : String) ->
150+replWith : (state : a) -> (prompt : String) ->
151151 (onInput : a -> String -> Maybe (String, a)) -> IO ()
152−replWith acc prompt fn
152+replWith acc prompt fn
153153 = do putStr prompt
154154 x <- getLine
155155 case fn acc x of
156− Just (out, acc') => do putStr out
156+ Just (out, acc') => do putStr out
157157 replWith acc' prompt fn
158158 Nothing => return ()
159159
160160||| A basic read-eval-print loop
161−||| @ prompt the prompt to show
161+||| @ prompt the prompt to show
162162||| @ onInput the function to run on reading input, returning a String to
163−||| output
163+||| output
164164partial
165−repl : (prompt : String) ->
165+repl : (prompt : String) ->
166166 (onInput : String -> String) -> IO ()
167−repl prompt fn
167+repl prompt fn
168168 = replWith () prompt (\x, s => Just (fn s, ()))
169−
libs/prelude/Prelude/Classes.idr → libs/prelude/Prelude/Interfaces.idrrenamed+9−11
@@ -1,4 +1,4 @@
1−module Prelude.Classes
1+module Prelude.Interfaces
22
33import Builtins
44import Prelude.Basics
@@ -57,7 +57,7 @@ Eq Bool where
5757 True == False = False
5858 False == True = False
5959 False == False = True
60−
60+
6161(Eq a, Eq b) => Eq (a, b) where
6262 (==) (a, c) (b, d) = (a == b) && (c == d)
6363
@@ -357,7 +357,7 @@ divB8 x y = case y == 0 of
357357modB8 : Bits8 -> Bits8 -> Bits8
358358modB8 x y = case y == 0 of
359359 False => prim__sremB8 x y
360−
360+
361361Integral Bits8 where
362362 div = divB8
363363 mod = modB8
@@ -372,8 +372,8 @@ modB16 x y = case y == 0 of
372372 False => prim__sremB16 x y
373373
374374Integral Bits16 where
375− div = divB16
376− mod = modB16
375+ div = divB16
376+ mod = modB16
377377
378378-- ------------------------------------------------------------------ [ Bits32 ]
379379divB32 : Bits32 -> Bits32 -> Bits32
@@ -385,8 +385,8 @@ modB32 x y = case y == 0 of
385385 False => prim__sremB32 x y
386386
387387Integral Bits32 where
388− div = divB32
389− mod = modB32
388+ div = divB32
389+ mod = modB32
390390
391391-- ------------------------------------------------------------------ [ Bits64 ]
392392divB64 : Bits64 -> Bits64 -> Bits64
@@ -398,7 +398,5 @@ modB64 x y = case y == 0 of
398398 False => prim__sremB64 x y
399399
400400Integral Bits64 where
401− div = divB64
402− mod = modB64
403−
404−
401+ div = divB64
402+ mod = modB64
libs/prelude/Prelude/List.idr+4−5
@@ -5,7 +5,7 @@ import Builtins
55import Prelude.Algebra
66import Prelude.Basics
77import Prelude.Bool
8−import Prelude.Classes
8+import Prelude.Interfaces
99import Prelude.Foldable
1010import Prelude.Functor
1111import Prelude.Maybe
@@ -174,7 +174,7 @@ init' [] = Nothing
174174init' (x::xs) =
175175 case xs of
176176 [] => Just []
177− y::ys =>
177+ y::ys =>
178178 case init' $ y::ys of
179179 Nothing => Nothing
180180 Just j => Just $ x :: j
@@ -305,7 +305,7 @@ zipWith f (x::xs) (y::ys) = f x y :: zipWith f xs ys
305305||| @ z the third list
306306zipWith3 : (f : a -> b -> c -> d) -> (x : List a) -> (y : List b) ->
307307 (z : List c) -> List d
308−zipWith3 f _ [] (z::zs) = []
308+zipWith3 f _ [] (z::zs) = []
309309zipWith3 f _ (y::ys) [] = []
310310zipWith3 f [] (y::ys) _ = []
311311zipWith3 f (x::xs) [] _ = []
@@ -761,7 +761,7 @@ mergeBy : (a -> a -> Ordering) -> List a -> List a -> List a
761761mergeBy order [] right = right
762762mergeBy order left [] = left
763763mergeBy order (x::xs) (y::ys) =
764− if order x y == LT
764+ if order x y == LT
765765 then x :: mergeBy order xs (y::ys)
766766 else y :: mergeBy order (x::xs) ys
767767
@@ -888,4 +888,3 @@ foldlAsFoldr f z t = foldr (flip (.) . flip f) id t z
888888foldlMatchesFoldr : (f : b -> a -> b) -> (q : b) -> (xs : List a) -> foldl f q xs = foldlAsFoldr f q xs
889889foldlMatchesFoldr f q [] = Refl
890890foldlMatchesFoldr f q (x :: xs) = foldlMatchesFoldr f (f q x) xs
891−
libs/prelude/Prelude/Maybe.idr+1−1
@@ -5,7 +5,7 @@ import Prelude.Algebra
55import Prelude.Basics
66import Prelude.Bool
77import Prelude.Cast
8−import Prelude.Classes
8+import Prelude.Interfaces
99import Prelude.Foldable
1010
1111%access public
libs/prelude/Prelude/Nat.idr+17−18
@@ -6,7 +6,7 @@ import Prelude.Algebra
66import Prelude.Basics
77import Prelude.Bool
88import Prelude.Cast
9−import Prelude.Classes
9+import Prelude.Interfaces
1010import Prelude.Uninhabited
1111
1212%access public
@@ -224,9 +224,9 @@ record Multiplicative where
224224
225225||| A wrapper for Nat that specifies the semigroup and monad implementations that use (+)
226226record Additive where
227− constructor GetAdditive
227+ constructor GetAdditive
228228 _ : Nat
229−
229+
230230Semigroup Multiplicative where
231231 (<+>) left right = GetMultiplicative $ left' * right'
232232 where
@@ -424,7 +424,7 @@ total plusCommutative : (left : Nat) -> (right : Nat) ->
424424plusCommutative Z right = rewrite plusZeroRightNeutral right in Refl
425425plusCommutative (S left) right =
426426 let inductiveHypothesis = plusCommutative left right in
427− rewrite inductiveHypothesis in
427+ rewrite inductiveHypothesis in
428428 rewrite plusSuccRightSucc right left in Refl
429429
430430total plusAssociative : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
@@ -450,21 +450,21 @@ total plusLeftCancel : (left : Nat) -> (right : Nat) -> (right' : Nat) ->
450450plusLeftCancel Z right right' p = p
451451plusLeftCancel (S left) right right' p =
452452 let inductiveHypothesis = plusLeftCancel left right right' in
453− inductiveHypothesis (succInjective _ _ p)
453+ inductiveHypothesis (succInjective _ _ p)
454454
455455total plusRightCancel : (left : Nat) -> (left' : Nat) -> (right : Nat) ->
456456 (p : left + right = left' + right) -> left = left'
457457plusRightCancel left left' Z p = rewrite sym (plusZeroRightNeutral left) in
458458 rewrite sym (plusZeroRightNeutral left') in
459− p
459+ p
460460plusRightCancel left left' (S right) p =
461− plusRightCancel left left' right
462− (succInjective _ _ (rewrite plusSuccRightSucc left right in
461+ plusRightCancel left left' right
462+ (succInjective _ _ (rewrite plusSuccRightSucc left right in
463463 rewrite plusSuccRightSucc left' right in p))
464464
465465total plusLeftLeftRightZero : (left : Nat) -> (right : Nat) ->
466466 (p : left + right = left) -> right = Z
467−plusLeftLeftRightZero Z right p = p
467+plusLeftLeftRightZero Z right p = p
468468plusLeftLeftRightZero (S left) right p =
469469 plusLeftLeftRightZero left right (succInjective _ _ p)
470470
@@ -481,7 +481,7 @@ total multRightSuccPlus : (left : Nat) -> (right : Nat) ->
481481multRightSuccPlus Z right = Refl
482482multRightSuccPlus (S left) right =
483483 let inductiveHypothesis = multRightSuccPlus left right in
484− rewrite inductiveHypothesis in
484+ rewrite inductiveHypothesis in
485485 rewrite plusAssociative left right (mult left right) in
486486 rewrite plusAssociative right left (mult left right) in
487487 rewrite plusCommutative right left in
@@ -493,11 +493,11 @@ multLeftSuccPlus left right = Refl
493493
494494total multCommutative : (left : Nat) -> (right : Nat) ->
495495 left * right = right * left
496−multCommutative Z right = rewrite multZeroRightZero right in Refl
496+multCommutative Z right = rewrite multZeroRightZero right in Refl
497497multCommutative (S left) right =
498498 let inductiveHypothesis = multCommutative left right in
499499 rewrite inductiveHypothesis in
500− rewrite multRightSuccPlus right left in
500+ rewrite multRightSuccPlus right left in
501501 Refl
502502
503503total multDistributesOverPlusRight : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
@@ -505,7 +505,7 @@ total multDistributesOverPlusRight : (left : Nat) -> (centre : Nat) -> (right :
505505multDistributesOverPlusRight Z centre right = Refl
506506multDistributesOverPlusRight (S left) centre right =
507507 let inductiveHypothesis = multDistributesOverPlusRight left centre right in
508− rewrite inductiveHypothesis in
508+ rewrite inductiveHypothesis in
509509 rewrite plusAssociative (plus centre (mult left centre)) right (mult left right) in
510510 rewrite sym (plusAssociative centre (mult left centre) right) in
511511 rewrite plusCommutative (mult left centre) right in
@@ -527,7 +527,7 @@ total multAssociative : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
527527multAssociative Z centre right = Refl
528528multAssociative (S left) centre right =
529529 let inductiveHypothesis = multAssociative left centre right in
530− rewrite inductiveHypothesis in
530+ rewrite inductiveHypothesis in
531531 rewrite multDistributesOverPlusLeft centre (mult left centre) right in
532532 Refl
533533
@@ -619,7 +619,7 @@ powerSuccPowerLeft base exp = Refl
619619
620620total multPowerPowerPlus : (base : Nat) -> (exp : Nat) -> (exp' : Nat) ->
621621 (power base exp) * (power base exp') = power base (exp + exp')
622−multPowerPowerPlus base Z exp' =
622+multPowerPowerPlus base Z exp' =
623623 rewrite sym (plusZeroRightNeutral (power base exp')) in Refl
624624multPowerPowerPlus base (S exp) exp' =
625625 let inductiveHypothesis = multPowerPowerPlus base exp exp' in
@@ -651,7 +651,7 @@ total powerPowerMultPower : (base : Nat) -> (exp : Nat) -> (exp' : Nat) ->
651651powerPowerMultPower base exp Z = rewrite multZeroRightZero exp in Refl
652652powerPowerMultPower base exp (S exp') =
653653 let inductiveHypothesis = powerPowerMultPower base exp exp' in
654− rewrite inductiveHypothesis in
654+ rewrite inductiveHypothesis in
655655 rewrite multRightSuccPlus exp exp' in
656656 rewrite sym (multPowerPowerPlus base exp (mult exp exp')) in
657657 Refl
@@ -664,7 +664,7 @@ total minusSuccPred : (left : Nat) -> (right : Nat) ->
664664 minus left (S right) = pred (minus left right)
665665minusSuccPred Z right = Refl
666666minusSuccPred (S left) Z =
667− rewrite minusZeroRight left in Refl
667+ rewrite minusZeroRight left in Refl
668668minusSuccPred (S left) (S right) =
669669 let inductiveHypothesis = minusSuccPred left right in
670670 rewrite inductiveHypothesis in Refl
@@ -782,4 +782,3 @@ sucMinL (S l) = cong (sucMinL l)
782782total sucMinR : (l : Nat) -> minimum l (S l) = l
783783sucMinR Z = Refl
784784sucMinR (S l) = cong (sucMinR l)
785−
libs/prelude/Prelude/Show.idr+1−2
@@ -7,7 +7,7 @@ import Prelude.Bits
77import Prelude.Bool
88import Prelude.Cast
99import Prelude.Chars
10−import Prelude.Classes
10+import Prelude.Interfaces
1111import Prelude.List
1212import Prelude.Maybe
1313import Prelude.Either
@@ -192,4 +192,3 @@ Show a => Show (Maybe a) where
192192
193193(Show a, {y : a} -> Show (p y)) => Show (Sigma a p) where
194194 show (y ** prf) = "(" ++ show y ++ " ** " ++ show prf ++ ")"
195−
libs/prelude/Prelude/Strings.idr+2−3
@@ -8,7 +8,7 @@ import Prelude.Basics
88import Prelude.Bool
99import Prelude.Chars
1010import Prelude.Cast
11−import Prelude.Classes
11+import Prelude.Interfaces
1212import Prelude.Either
1313import Prelude.Foldable
1414import Prelude.Functor
@@ -112,7 +112,7 @@ strTail' x p = assert_total $ prim__strTail x
112112-- we need the 'believe_me' because the operations are primitives
113113strM : (x : String) -> StrM x
114114strM x with (decEq (not (x == "")) True)
115− strM x | (Yes p) = really_believe_me $
115+ strM x | (Yes p) = really_believe_me $
116116 StrCons (assert_total (strHead' x p))
117117 (assert_total (strTail' x p))
118118 strM x | (No p) = really_believe_me StrNil
@@ -364,4 +364,3 @@ partial
364364nullStr : String -> IO Bool
365365nullStr p = do ok <- foreign FFI_C "isNull" (String -> IO Int) p
366366 return (ok /= 0)
367−
libs/prelude/prelude.ipkg+1−2
@@ -4,7 +4,7 @@ opts = "--nobuiltins --total --no-elim-deprecation-warnings"
44modules = Builtins, Prelude, IO,
55
66 Prelude.Algebra, Prelude.Basics, Prelude.Bool, Prelude.Cast,
7− Prelude.Classes, Prelude.Nat, Prelude.List,
7+ Prelude.Interfaces, Prelude.Nat, Prelude.List,
88 Prelude.Maybe, Prelude.Monad, Prelude.Applicative, Prelude.Either,
99 Prelude.Strings, Prelude.Chars, Prelude.Show, Prelude.Functor,
1010 Prelude.Foldable, Prelude.Traversable, Prelude.Bits, Prelude.Stream,
@@ -14,4 +14,3 @@ modules = Builtins, Prelude, IO,
1414 Language.Reflection, Language.Reflection.Errors, Language.Reflection.Elab,
1515
1616 Decidable.Equality
17−
src/Idris/ProofSearch.hs+31−33
@@ -48,13 +48,13 @@ trivialHoles psnames ok elab ist
4848 then try' (elab (PRef (fileFC "prf") [] x))
4949 (tryAll xs) True
5050 else tryAll xs
51−
51+
5252 holesOK hs ap@(App _ _ _)
5353 | (P _ n _, args) <- unApply ap
5454 = holeArgsOK hs n 0 args
5555 holesOK hs (App _ f a) = holesOK hs f && holesOK hs a
5656 holesOK hs (P _ n _) = not (n `elem` hs)
57− holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
57+ holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
5858 holesOK hs sc
5959 holesOK hs _ = True
6060
@@ -85,8 +85,8 @@ trivialTCs ok elab ist
8585 then try' (elab (PRef (fileFC "prf") [] x))
8686 (tryAll xs) True
8787 else tryAll xs
88−
89− tcArg env ty
88+
89+ tcArg env ty
9090 | (P _ n _, args) <- unApply (getRetTy (normalise (tt_ctxt ist) env ty))
9191 = case lookupCtxtExact n (idris_classes ist) of
9292 Just _ -> True
@@ -98,7 +98,7 @@ trivialTCs ok elab ist
9898 = holeArgsOK hs n 0 args
9999 holesOK hs (App _ f a) = holesOK hs f && holesOK hs a
100100 holesOK hs (P _ n _) = not (n `elem` hs)
101− holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
101+ holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
102102 holesOK hs sc
103103 holesOK hs _ = True
104104
@@ -111,16 +111,16 @@ cantSolveGoal :: ElabD a
111111cantSolveGoal = do g <- goal
112112 env <- get_env
113113 lift $ tfail $
114− CantSolveGoal g (map (\(n,b) -> (n, binderTy b)) env)
114+ CantSolveGoal g (map (\(n,b) -> (n, binderTy b)) env)
115115
116−proofSearch :: Bool -> -- recursive search (False for 'refine')
116+proofSearch :: Bool -> -- recursive search (False for 'refine')
117117 Bool -> -- invoked from a tactic proof. If so, making
118118 -- new metavariables is meaningless, and there shoudl
119119 -- be an error reported instead.
120120 Bool -> -- ambiguity ok
121121 Bool -> -- defer on failure
122122 Int -> -- maximum depth
123− (PTerm -> ElabD ()) -> Maybe Name -> Name ->
123+ (PTerm -> ElabD ()) -> Maybe Name -> Name ->
124124 [Name] ->
125125 [Name] ->
126126 IState -> ElabD ()
@@ -131,7 +131,7 @@ proofSearch False fromProver ambigok deferonfail depth elab _ nroot psnames [fn]
131131 tryAllFns all_imps
132132 where
133133 -- if nothing worked, make a new metavariable
134− tryAllFns [] | fromProver = cantSolveGoal
134+ tryAllFns [] | fromProver = cantSolveGoal
135135 tryAllFns [] = do attack; defer [] nroot; solve
136136 tryAllFns (f : fs) = try' (tryFn f) (tryAllFns fs) True
137137
@@ -142,20 +142,20 @@ proofSearch False fromProver ambigok deferonfail depth elab _ nroot psnames [fn]
142142 (match_apply (Var f) imps) True
143143 ps' <- get_probs
144144-- when (length ps < length ps') $ fail "Can't apply constructor"
145− -- Make metavariables for new holes
145+ -- Make metavariables for new holes
146146 hs' <- get_holes
147147 ptm <- get_term
148148 if fromProver then cantSolveGoal
149149 else do
150150 mapM_ (\ h -> do focus h
151− attack; defer [] nroot; solve)
151+ attack; defer [] nroot; solve)
152152 (hs' \\ hs)
153153-- (filter (\ (x, y) -> not x) (zip (map fst imps) args))
154154 solve
155155
156156 isImp (PImp p _ _ _ _) = (True, p)
157157 isImp arg = (True, priority arg) -- try to get all of them by unification
158−proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hints ist
158+proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hints ist
159159 = do compute
160160 ty <- goal
161161 hs <- get_holes
@@ -172,7 +172,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
172172 (autoArg (sUN "auto"))
173173 else autoArg (sUN "auto") -- not enough info in the type yet
174174 where
175− findInferredTy (t : _) = elab (delab ist (toUN t))
175+ findInferredTy (t : _) = elab (delab ist (toUN t))
176176
177177 cantsolve (InternalMsg _) = True
178178 cantsolve (CantSolveGoal _ _) = True
@@ -185,12 +185,12 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
185185 conArgsOK ty
186186 = let (f, as) = unApply ty in
187187 case f of
188− P _ n _ ->
188+ P _ n _ ->
189189 let autohints = case lookupCtxtExact n (idris_autohints ist) of
190190 Nothing -> []
191191 Just hs -> hs in
192192 case lookupCtxtExact n (idris_datatypes ist) of
193− Just t -> do rs <- mapM (conReady as)
193+ Just t -> do rs <- mapM (conReady as)
194194 (autohints ++ con_names t)
195195 return (and rs)
196196 Nothing -> -- local variable, go for it
@@ -199,7 +199,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
199199 _ -> typeNotSearchable ty
200200
201201 conReady :: [Term] -> Name -> ElabD Bool
202− conReady as n
202+ conReady as n
203203 = case lookupTyExact n (tt_ctxt ist) of
204204 Just ty -> do let (_, cs) = unApply (getRetTy ty)
205205 -- if any metavariables in 'as' correspond to
@@ -223,7 +223,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
223223 inHS hs (P _ n _) = n `elem` hs
224224 isHS _ _ = False
225225
226− toUN t@(P nt (MN i n) ty)
226+ toUN t@(P nt (MN i n) ty)
227227 | ('_':xs) <- str n = t
228228 | otherwise = P nt (UN n) ty
229229 toUN (App s f a) = App s (toUN f) (toUN a)
@@ -239,7 +239,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
239239 psRec :: Bool -> Int -> [Name] -> S.Set Type -> ElabD ()
240240 psRec _ 0 locs tys | fromProver = cantSolveGoal
241241 psRec rec 0 locs tys = do attack; defer [] nroot; solve --fail "Maximum depth reached"
242− psRec False d locs tys = tryCons d locs tys hints
242+ psRec False d locs tys = tryCons d locs tys hints
243243 psRec True d locs tys
244244 = do compute
245245 ty <- goal
@@ -248,11 +248,11 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
248248 try' (try' (trivialHoles psnames [] elab ist)
249249 (resolveTC False False 20 ty nroot elab ist)
250250 True)
251− (try' (try' (resolveByCon (d - 1) locs tys')
251+ (try' (try' (resolveByCon (d - 1) locs tys')
252252 (resolveByLocals (d - 1) locs tys')
253253 True)
254254 -- if all else fails, make a new metavariable
255− (if fromProver
255+ (if fromProver
256256 then fail "cantSolveGoal"
257257 else do attack; defer [] nroot; solve) True) True
258258
@@ -269,7 +269,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
269269 = do t <- goal
270270 let (f, _) = unApply t
271271 case f of
272− P _ n _ ->
272+ P _ n _ ->
273273 do let autohints = case lookupCtxtExact n (idris_autohints ist) of
274274 Nothing -> []
275275 Just hs -> hs
@@ -292,26 +292,26 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
292292 tryLocals d locs tys env
293293
294294 tryLocals d locs tys [] = fail "Locals failed"
295− tryLocals d locs tys ((x, t) : xs)
295+ tryLocals d locs tys ((x, t) : xs)
296296 | x `elem` locs || x `notElem` psnames = tryLocals d locs tys xs
297− | otherwise = try' (tryLocal d (x : locs) tys x t)
297+ | otherwise = try' (tryLocal d (x : locs) tys x t)
298298 (tryLocals d locs tys xs) True
299299
300300 tryCons d locs tys [] = fail "Constructors failed"
301− tryCons d locs tys (c : cs)
301+ tryCons d locs tys (c : cs)
302302 = try' (tryCon d locs tys c) (tryCons d locs tys cs) True
303303
304− tryLocal d locs tys n t
304+ tryLocal d locs tys n t
305305 = do let a = getPArity (delab ist (binderTy t))
306306 tryLocalArg d locs tys n a
307307
308308 tryLocalArg d locs tys n 0 = elab (PRef (fileFC "prf") [] n)
309− tryLocalArg d locs tys n i
309+ tryLocalArg d locs tys n i
310310 = simple_app False (tryLocalArg d locs tys n (i - 1))
311311 (psRec True d locs tys) "proof search local apply"
312312
313313 -- Like type class resolution, but searching with constructors
314− tryCon d locs tys n =
314+ tryCon d locs tys n =
315315 do ty <- goal
316316 let imps = case lookupCtxtExact n (idris_implicits ist) of
317317 Nothing -> []
@@ -341,7 +341,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
341341 (Bind _ (Pi _ _ _) _) -> [TextPart "In particular, function types are not supported."]
342342 _ -> []
343343
344−-- In interactive mode, only search for things if there is some
344+-- In interactive mode, only search for things if there is some
345345-- index to help pick a relevant constructor
346346checkConstructor :: IState -> [Name] -> ElabD ()
347347checkConstructor ist [] = return ()
@@ -397,7 +397,7 @@ resTC' tcs defaultOn topholes depth topg fn elab ist
397397 _ -> []
398398
399399 traceWhen ulog ("Resolving class " ++ show g ++ "\nin" ++ show env ++ "\n" ++ show okholes) $
400− try' (trivialTCs okholes elab ist)
400+ try' (trivialTCs okholes elab ist)
401401 (do addDefault t tc ttypes
402402 let stk = map fst (filter snd $ elab_stack ist)
403403 let insts = findInstances ist t
@@ -432,7 +432,7 @@ resTC' tcs defaultOn topholes depth topg fn elab ist
432432 tcDetArgsOK _ _ _ [] = Just []
433433
434434 isMeta :: [Name] -> Term -> Bool
435− isMeta ns (P _ n _) = n `elem` ns
435+ isMeta ns (P _ n _) = n `elem` ns
436436 isMeta _ _ = False
437437
438438 notHole hs (P _ n _, c)
@@ -449,7 +449,7 @@ resTC' tcs defaultOn topholes depth topg fn elab ist
449449 chaser (NS n _) = chaser n
450450 chaser _ = False
451451
452− numclass = sNS (sUN "Num") ["Classes","Prelude"]
452+ numclass = sNS (sUN "Num") ["Interfaces","Prelude"]
453453
454454 addDefault t num@(P _ nc _) [P Bound a _] | nc == numclass && defaultOn
455455 = do focus a
@@ -530,5 +530,3 @@ findInstances ist t
530530 where accessible n = case lookupDefAccExact n False (tt_ctxt ist) of
531531 Just (_, Hidden) -> False
532532 _ -> True
533−
534−
test/interactive010/expected+3−3
@@ -1,12 +1,12 @@
11Prelude.List.(++) : List a -> List a -> List a
22Prelude.Strings.(++) : String -> String -> String
3−a is not an implicit argument of Prelude.Classes./
3+a is not an implicit argument of Prelude.Interfaces./
44Usage is :doc <functionname>
55Usage is :wc <functionname>
66Usage is :printdef <functionname>
7−pat {ty504} : Type u. pat {__class505} : Prelude.Classes.Fractional {ty504}. Prelude.Classes./ {ty504} {__class505}
7+pat {ty504} : Type u. pat {__class505} : Prelude.Interfaces.Fractional {ty504}. Prelude.Interfaces./ {ty504} {__class505}
88
9− : pty {ty504} : Type u. pty {__class505} : Prelude.Classes.Fractional {ty504}. {ty504} -> {ty504} -> {ty504}
9+ : pty {ty504} : Type u. pty {__class505} : Prelude.Interfaces.Fractional {ty504}. {ty504} -> {ty504} -> {ty504}
1010(input):1:1: error: expected: ":",
1111 dependent type signature,
1212 end of input
test/syntax001/expected+2−2
@@ -2,7 +2,7 @@ Syntax.idr:6:7-9:1:
22When checking right hand side of foo with expected type
33 Nat
44
5−When checking an application of function Prelude.Classes.+:
5+When checking an application of function Prelude.Interfaces.+:
66 Type mismatch between
77 String (Type of "argh")
88 and
@@ -11,7 +11,7 @@ SyntaxTest.idr:5:7-6:1:
1111When checking right hand side of foo with expected type
1212 Nat
1313
14−When checking an application of function Prelude.Classes.+:
14+When checking an application of function Prelude.Interfaces.+:
1515 Type mismatch between
1616 String (Type of "argh")
1717 and