on master help sign in
Merge branch 'master' of github.com:idris-lang/Idris-dev into liftDecls_js_backend
commitcb4f9e6bf48967d579580ddd2927797ca75c36e7 authorRui Barreiro <rui.barreiro@gmail.com> dateSun 7 May 2017, 16:17 (9 years ago) parente1d16e2fcbabc2
21 files changed+225−88
README.md+1−3 idris.cabal+1−1 libs/contrib/Control/Algebra/NumericImplementations.idr+26−6 libs/contrib/Control/ST.idr+3−5 libs/contrib/Data/SortedMap.idr+2−2 libs/contrib/Data/SortedSet.idr+27−3 libs/contrib/Interfaces/Verified.idr+81−37 libs/contrib/Network/Socket.idr+1 libs/contrib/contrib.ipkg+1 src/IRTS/System.hs+4−3 src/Idris/Coverage.hs+29−12 src/Idris/Elab/Clause.hs+1−1 src/Idris/IBC.hs+12−12 src/Idris/Termination.hs+2−2 test/TestData.hs+2−1 test/regression002/Canonicity.idr+13 test/regression002/expected+2 test/regression002/run+1 test/totality023/expected+2 test/totality023/run+3 test/totality023/totality023.idr+11
README.md+1−3
@@ -28,9 +28,7 @@ Idris has support for external code generators. Supplied with the distribution
2828is a C code generator to compile executables, and a JavaScript code generator
2929with support for node.js and browser JavaScript.
3030
31−At this moment in time there are two external repositories with a
32−[Java code generator](https://github.com/idris-hackers/idris-java) and an
33−[LLVM-based code generator](https://github.com/idris-hackers/idris-llvm).
31+More information about [code generators can be found on the wiki](http://idris.readthedocs.io/en/latest/reference/codegen.html).
3432
3533## More Information
3634
idris.cabal+1−1
@@ -358,7 +358,7 @@ Executable idris
358358 , transformers
359359
360360 ghc-prof-options: -auto-all -caf-all
361− ghc-options: -threaded -rtsopts -funbox-strict-fields
361+ ghc-options: -threaded -rtsopts -funbox-strict-fields -with-rtsopts=-I0
362362
363363Test-suite regression-and-feature-tests
364364 Type: exitcode-stdio-1.0
libs/contrib/Control/Algebra/NumericImplementations.idr+26−6
@@ -9,6 +9,8 @@ import Data.ZZ
99
1010%access public export
1111
12+-- Integer
13+
1214Semigroup Integer where
1315 (<+>) = (+)
1416
@@ -18,7 +20,7 @@ Monoid Integer where
1820Group Integer where
1921 inverse = (* -1)
2022
21−AbelianGroup Integer where
23+AbelianGroup Integer where
2224
2325Ring Integer where
2426 (<.>) = (*)
@@ -26,6 +28,7 @@ Ring Integer where
2628RingWithUnity Integer where
2729 unity = 1
2830
31+-- Int
2932
3033Semigroup Int where
3134 (<+>) = (+)
@@ -44,6 +47,7 @@ Ring Int where
4447RingWithUnity Int where
4548 unity = 1
4649
50+-- Double
4751
4852Semigroup Double where
4953 (<+>) = (+)
@@ -65,30 +69,46 @@ RingWithUnity Double where
6569Field Double where
6670 inverseM f _ = 1 / f
6771
72+-- Nat
6873
69−Semigroup Nat where
74+[PlusNatSemi] Semigroup Nat where
7075 (<+>) = (+)
7176
72−Monoid Nat where
77+[PlusNatMonoid] Monoid Nat using PlusNatSemi where
7378 neutral = 0
7479
75−Semigroup ZZ where
80+[MultNatSemi] Semigroup Nat where
81+ (<+>) = (*)
82+
83+[MultNatMonoid] Monoid Nat using MultNatSemi where
84+ neutral = 1
85+
86+-- ZZ
87+
88+[PlusZZSemi] Semigroup ZZ where
7689 (<+>) = (+)
7790
78−Monoid ZZ where
91+[PlusZZMonoid] Monoid ZZ using PlusZZSemi where
7992 neutral = 0
8093
81−Group ZZ where
94+Group ZZ using PlusZZMonoid where
8295 inverse = (* -1)
8396
8497AbelianGroup ZZ where
8598
99+[MultZZSemi] Semigroup ZZ where
100+ (<+>) = (*)
101+
102+[MultZZMonoid] Monoid ZZ using MultZZSemi where
103+ neutral = 1
104+
86105Ring ZZ where
87106 (<.>) = (*)
88107
89108RingWithUnity ZZ where
90109 unity = 1
91110
111+-- Complex
92112
93113Semigroup a => Semigroup (Complex a) where
94114 (<+>) (a :+ b) (c :+ d) = (a <+> c) :+ (b <+> d)
libs/contrib/Control/ST.idr+3−5
@@ -593,15 +593,13 @@ runLoop fuel prog onEmpty
593593||| responsibility of an implementation of an interface in IO which uses it
594594||| to ensure that it isn't duplicated.
595595export
596−runWith : {resf : _} ->
597− Env res -> STrans IO a res (\result => resf result) ->
596+runWith : Env res -> STrans IO a res resf ->
598597 IO (result ** Env (resf result))
599598runWith env prog = runST env prog (\res, env' => pure (res ** env'))
600599
601600export
602−runWithLoop : {resf : _} ->
603− Env res -> Fuel -> STransLoop IO a res (\result => resf result) ->
604− IO (Maybe (result ** Env (resf result)))
601+runWithLoop : Env res -> Fuel -> STransLoop IO a res resf ->
602+ IO (Maybe (result ** Env (resf result)))
605603runWithLoop env fuel prog
606604 = runSTLoop fuel env prog (\res, env' => pure (Just (res ** env')))
607605 (pure Nothing)
libs/contrib/Data/SortedMap.idr+2−2
@@ -238,10 +238,10 @@ toList (M _ t) = treeToList t
238238treeMap : (a -> b) -> Tree n k a o -> Tree n k b o
239239treeMap f (Leaf k v) = Leaf k (f v)
240240treeMap f (Branch2 t1 k t2) = Branch2 (treeMap f t1) k (treeMap f t2)
241−treeMap f (Branch3 t1 k1 t2 k2 t3)
241+treeMap f (Branch3 t1 k1 t2 k2 t3)
242242 = Branch3 (treeMap f t1) k1 (treeMap f t2) k2 (treeMap f t3)
243243
244+export
244245implementation Functor (SortedMap k) where
245246 map _ Empty = Empty
246247 map f (M n t) = M _ (treeMap f t)
247−
libs/contrib/Data/SortedSet.idr+27−3
@@ -2,8 +2,6 @@ module Data.SortedSet
22
33import Data.SortedMap
44
5−-- TODO: add intersection, union, difference
6−
75export
86data SortedSet k = SetWrapper (Data.SortedMap.SortedMap k ())
97
@@ -31,5 +29,31 @@ export
3129toList : SortedSet k -> List k
3230toList (SetWrapper m) = map (\(i, _) => i) (Data.SortedMap.toList m)
3331
34−implementation Foldable SortedSet where
32+Foldable SortedSet where
3533 foldr f e xs = foldr f e (Data.SortedSet.toList xs)
34+
35+||| Set union. Inserts all elements of x into y
36+export
37+union : (x, y : SortedSet k) -> SortedSet k
38+union x y = foldr insert x y
39+
40+||| Set difference. Delete all elments in y from x
41+export
42+difference : (x, y : SortedSet k) -> SortedSet k
43+difference x y = foldr delete x y
44+
45+||| Set symmetric difference. Uses the union of the differences.
46+export
47+symDifference : (x, y : SortedSet k) -> SortedSet k
48+symDifference x y = union (difference x y) (difference y x)
49+
50+||| Set intersection. Implemented as the difference of the union and the symetric difference.
51+export
52+intersection : (x, y : SortedSet k) -> SortedSet k
53+intersection x y = difference x (difference x y)
54+
55+Ord k => Semigroup (SortedSet k) where
56+ (<+>) = union
57+
58+Ord k => Monoid (SortedSet k) where
59+ neutral = empty
libs/contrib/Interfaces/Verified.idr+81−37
@@ -2,7 +2,9 @@ module Interfaces.Verified
22
33import Control.Algebra
44import Control.Algebra.Lattice
5+import Control.Algebra.NumericImplementations
56import Control.Algebra.VectorSpace
7+import Data.ZZ
68
79%access public export
810
@@ -19,6 +21,12 @@ interface Functor f => VerifiedFunctor (f : Type -> Type) where
1921 (g1 : a -> b) -> (g2 : b -> c) ->
2022 map (g2 . g1) x = (map g2 . map g1) x
2123
24+VerifiedFunctor Maybe where
25+ functorIdentity Nothing = Refl
26+ functorIdentity (Just x) = Refl
27+ functorComposition Nothing g1 g2 = Refl
28+ functorComposition (Just x) g1 g2 = Refl
29+
2230interface (Applicative f, VerifiedFunctor f) => VerifiedApplicative (f : Type -> Type) where
2331 applicativeMap : (x : f a) -> (g : a -> b) ->
2432 map g x = pure g <*> x
@@ -30,6 +38,23 @@ interface (Applicative f, VerifiedFunctor f) => VerifiedApplicative (f : Type ->
3038 applicativeInterchange : (x : a) -> (g : f (a -> b)) ->
3139 g <*> pure x = pure (\g' : (a -> b) => g' x) <*> g
3240
41+VerifiedApplicative Maybe where
42+ applicativeMap Nothing g = Refl
43+ applicativeMap (Just x) g = Refl
44+ applicativeIdentity Nothing = Refl
45+ applicativeIdentity (Just x) = Refl
46+ applicativeComposition Nothing Nothing Nothing = Refl
47+ applicativeComposition Nothing Nothing (Just x) = Refl
48+ applicativeComposition Nothing (Just x) Nothing = Refl
49+ applicativeComposition Nothing (Just x) (Just y) = Refl
50+ applicativeComposition (Just x) Nothing Nothing = Refl
51+ applicativeComposition (Just x) Nothing (Just y) = Refl
52+ applicativeComposition (Just x) (Just y) Nothing = Refl
53+ applicativeComposition (Just x) (Just y) (Just z) = Refl
54+ applicativeHomomorphism x g = Refl
55+ applicativeInterchange x Nothing = Refl
56+ applicativeInterchange x (Just y) = Refl
57+
3358interface (Monad m, VerifiedApplicative m) => VerifiedMonad (m : Type -> Type) where
3459 monadApplicative : (mf : m (a -> b)) -> (mx : m a) ->
3560 mf <*> mx = mf >>= \f =>
@@ -40,6 +65,16 @@ interface (Monad m, VerifiedApplicative m) => VerifiedMonad (m : Type -> Type) w
4065 monadAssociativity : (mx : m a) -> (f : a -> m b) -> (g : b -> m c) ->
4166 (mx >>= f) >>= g = mx >>= (\x => f x >>= g)
4267
68+VerifiedMonad Maybe where
69+ monadApplicative Nothing Nothing = Refl
70+ monadApplicative Nothing (Just x) = Refl
71+ monadApplicative (Just x) Nothing = Refl
72+ monadApplicative (Just x) (Just y) = Refl
73+ monadLeftIdentity x f = Refl
74+ monadRightIdentity Nothing = Refl
75+ monadRightIdentity (Just x) = Refl
76+ monadAssociativity Nothing f g = Refl
77+ monadAssociativity (Just x) f g = Refl
4378
4479interface Semigroup a => VerifiedSemigroup a where
4580 total semigroupOpIsAssociative : (l, c, r : a) -> l <+> (c <+> r) = (l <+> c) <+> r
@@ -47,17 +82,37 @@ interface Semigroup a => VerifiedSemigroup a where
4782implementation VerifiedSemigroup (List a) where
4883 semigroupOpIsAssociative = appendAssociative
4984
50−--implementation VerifiedSemigroup Nat where
51−-- semigroupOpIsAssociative = plusAssociative
85+[PlusNatSemiV] VerifiedSemigroup Nat using PlusNatSemi where
86+ semigroupOpIsAssociative = plusAssociative
87+
88+[MultNatSemiV] VerifiedSemigroup Nat using MultNatSemi where
89+ semigroupOpIsAssociative = multAssociative
5290
91+[PlusZZSemiV] VerifiedSemigroup ZZ using PlusZZSemi where
92+ semigroupOpIsAssociative = plusAssociativeZ
93+
94+[MultZZSemiV] VerifiedSemigroup ZZ using MultZZSemi where
95+ semigroupOpIsAssociative = multAssociativeZ
5396
5497interface (VerifiedSemigroup a, Monoid a) => VerifiedMonoid a where
5598 total monoidNeutralIsNeutralL : (l : a) -> l <+> Algebra.neutral = l
5699 total monoidNeutralIsNeutralR : (r : a) -> Algebra.neutral <+> r = r
57100
58−-- implementation VerifiedMonoid Nat where
59−-- monoidNeutralIsNeutralL = plusZeroRightNeutral
60−-- monoidNeutralIsNeutralR = plusZeroLeftNeutral
101+[PlusNatMonoidV] VerifiedMonoid Nat using PlusNatSemiV, PlusNatMonoid where
102+ monoidNeutralIsNeutralL = plusZeroRightNeutral
103+ monoidNeutralIsNeutralR = plusZeroLeftNeutral
104+
105+[MultNatMonoidV] VerifiedMonoid Nat using MultNatSemiV, MultNatMonoid where
106+ monoidNeutralIsNeutralL = multOneRightNeutral
107+ monoidNeutralIsNeutralR = multOneLeftNeutral
108+
109+[PlusZZMonoidV] VerifiedMonoid ZZ using PlusZZSemiV, PlusZZMonoid where
110+ monoidNeutralIsNeutralL = plusZeroRightNeutralZ
111+ monoidNeutralIsNeutralR = plusZeroLeftNeutralZ
112+
113+[MultZZMonoidV] VerifiedMonoid ZZ using MultZZSemiV, MultZZMonoid where
114+ monoidNeutralIsNeutralL = multOneRightNeutralZ
115+ monoidNeutralIsNeutralR = multOneLeftNeutralZ
61116
62117implementation VerifiedMonoid (List a) where
63118 monoidNeutralIsNeutralL = appendNilRightNeutral
@@ -67,22 +122,39 @@ interface (VerifiedMonoid a, Group a) => VerifiedGroup a where
67122 total groupInverseIsInverseL : (l : a) -> l <+> inverse l = Algebra.neutral
68123 total groupInverseIsInverseR : (r : a) -> inverse r <+> r = Algebra.neutral
69124
125+VerifiedGroup ZZ using PlusZZMonoidV where
126+ groupInverseIsInverseL k = rewrite sym $ multCommutativeZ (NegS 0) k in
127+ rewrite multNegLeftZ 0 k in
128+ rewrite multOneLeftNeutralZ k in
129+ plusNegateInverseLZ k
130+ groupInverseIsInverseR k = rewrite sym $ multCommutativeZ (NegS 0) k in
131+ rewrite multNegLeftZ 0 k in
132+ rewrite multOneLeftNeutralZ k in
133+ plusNegateInverseRZ k
134+
70135interface (VerifiedGroup a, AbelianGroup a) => VerifiedAbelianGroup a where
71136 total abelianGroupOpIsCommutative : (l, r : a) -> l <+> r = r <+> l
72137
138+VerifiedAbelianGroup ZZ where
139+ abelianGroupOpIsCommutative = plusCommutativeZ
140+
73141interface (VerifiedAbelianGroup a, Ring a) => VerifiedRing a where
74142 total ringOpIsAssociative : (l, c, r : a) -> l <.> (c <.> r) = (l <.> c) <.> r
75143 total ringOpIsDistributiveL : (l, c, r : a) -> l <.> (c <+> r) = (l <.> c) <+> (l <.> r)
76144 total ringOpIsDistributiveR : (l, c, r : a) -> (l <+> c) <.> r = (l <.> r) <+> (c <.> r)
77145
146+VerifiedRing ZZ where
147+ ringOpIsAssociative = multAssociativeZ
148+ ringOpIsDistributiveL = multDistributesOverPlusRightZ
149+ ringOpIsDistributiveR = multDistributesOverPlusLeftZ
150+
78151interface (VerifiedRing a, RingWithUnity a) => VerifiedRingWithUnity a where
79152 total ringWithUnityIsUnityL : (l : a) -> l <.> Algebra.unity = l
80153 total ringWithUnityIsUnityR : (r : a) -> Algebra.unity <.> r = r
81154
82−--interface (VerifiedRingWithUnity a, Field a) => VerifiedField a where
83−-- total fieldInverseIsInverseL : (l : a) -> (notId : Not (l = neutral)) -> l <.> (inverseM l notId) = Algebra.unity
84−-- total fieldInverseIsInverseR : (r : a) -> (notId : Not (r = neutral)) -> (inverseM r notId) <.> r = Algebra.unity
85−
155+VerifiedRingWithUnity ZZ where
156+ ringWithUnityIsUnityL = multOneRightNeutralZ
157+ ringWithUnityIsUnityR = multOneLeftNeutralZ
86158
87159interface JoinSemilattice a => VerifiedJoinSemilattice a where
88160 total joinSemilatticeJoinIsAssociative : (l, c, r : a) -> join l (join c r) = join (join l c) r
@@ -93,31 +165,3 @@ interface MeetSemilattice a => VerifiedMeetSemilattice a where
93165 total meetSemilatticeMeetIsAssociative : (l, c, r : a) -> meet l (meet c r) = meet (meet l c) r
94166 total meetSemilatticeMeetIsCommutative : (l, r : a) -> meet l r = meet r l
95167 total meetSemilatticeMeetIsIdempotent : (e : a) -> meet e e = e
96−
97−{- FIXME: Some maintenance required here.
98− Algebra.top and Algebra.bottom don't exist!
99−-}
100−{-
101−
102−interface (VerifiedJoinSemilattice a, BoundedJoinSemilattice a) => VerifiedBoundedJoinSemilattice a where
103− total boundedJoinSemilatticeBottomIsBottom : (e : a) -> join e Algebra.bottom = e
104−
105−interface (VerifiedMeetSemilattice a, BoundedMeetSemilattice a) => VerifiedBoundedMeetSemilattice a where
106− total boundedMeetSemilatticeTopIsTop : (e : a) -> meet e Algebra.top = e
107−
108−interface (VerifiedJoinSemilattice a, VerifiedMeetSemilattice a) => VerifiedLattice a where
109− total latticeMeetAbsorbsJoin : (l, r : a) -> meet l (join l r) = l
110− total latticeJoinAbsorbsMeet : (l, r : a) -> join l (meet l r) = l
111−
112−interface (VerifiedBoundedJoinSemilattice a, VerifiedBoundedMeetSemilattice a, VerifiedLattice a) => VerifiedBoundedLattice a where { }
113−
114−
115−--interface (VerifiedRingWithUnity a, VerifiedAbelianGroup b, Module a b) => VerifiedModule a b where
116−-- total moduleScalarMultiplyComposition : (x,y : a) -> (v : b) -> x <#> (y <#> v) = (x <.> y) <#> v
117−-- total moduleScalarUnityIsUnity : (v : b) -> Algebra.unity {a} <#> v = v
118−-- total moduleScalarMultDistributiveWRTVectorAddition : (s : a) -> (v, w : b) -> s <#> (v <+> w) = (s <#> v) <+> (s <#> w)
119−-- total moduleScalarMultDistributiveWRTModuleAddition : (s, t : a) -> (v : b) -> (s <+> t) <#> v = (s <#> v) <+> (t <#> v)
120−
121−--interface (VerifiedField a, VerifiedModule a b) => VerifiedVectorSpace a b where {}
122−
123−-}
libs/contrib/Network/Socket.idr+1
@@ -10,6 +10,7 @@ import Network.Socket.Raw
1010%include C "idris_net.h"
1111%include C "sys/types.h"
1212%include C "sys/socket.h"
13+%include C "unistd.h"
1314%include C "netdb.h"
1415
1516%access export
libs/contrib/contrib.ipkg+1
@@ -8,6 +8,7 @@ modules = CFFI, CFFI.Types, CFFI.Memory,
88 Control.Algebra.NumericImplementations,
99 Control.Isomorphism.Primitives,
1010 Control.Partial,
11+ Control.Pipeline,
1112 Control.ST, Control.ST.ImplicitCall, Control.ST.Exception,
1213
1314 Interfaces.Verified,
src/IRTS/System.hs+4−3
@@ -30,7 +30,8 @@ import Control.Applicative ((<$>))
3030import Data.List.Split
3131import Data.Maybe (fromMaybe)
3232import System.Environment
33−import System.FilePath (addTrailingPathSeparator, (</>))
33+import System.FilePath (addTrailingPathSeparator, dropTrailingPathSeparator,
34+ (</>))
3435
3536
3637getIdrisDataDir :: IO String
@@ -81,7 +82,7 @@ gmpLib = []
8182#endif
8283
8384getLibFlags = do dir <- getIdrisCRTSDir
84− return $ ["-L" ++ dir,
85+ return $ ["-L" ++ dropTrailingPathSeparator dir,
8586 "-lidris_rts"] ++ extraLib ++ gmpLib ++ ["-lpthread"]
8687
8788getIdrisLibDir = addTrailingPathSeparator <$> overrideIdrisSubDirWith "libs" "IDRIS_LIBRARY_PATH"
@@ -97,4 +98,4 @@ getIdrisCRTSDir = do
9798 return $ addTrailingPathSeparator (ddir </> "rts")
9899
99100getIncFlags = do dir <- getIdrisCRTSDir
100− return $ ("-I" ++ dir) : extraInclude
101+ return $ ("-I" ++ dropTrailingPathSeparator dir) : extraInclude
src/Idris/Coverage.hs+29−12
@@ -410,31 +410,43 @@ recoverableCoverage _ _ = False
410410-- with
411411checkRec :: Term -> Term -> State [(Name, Term)] Bool
412412checkRec (P Bound x _) tm
413− | (P yt _ _, _) <- unApply tm,
414− conType yt = do nmap <- get
415− case lookup x nmap of
416− Nothing -> do put ((x, tm) : nmap)
417− return True
418− Just y' -> checkRec tm y'
413+ | isCon tm = do nmap <- get
414+ case lookup x nmap of
415+ Nothing -> do put ((x, tm) : nmap)
416+ return True
417+ Just y' -> checkRec tm y'
419418 where
419+ isCon tm
420+ | (P yt _ _, _) <- unApply tm,
421+ conType yt = True
422+ isCon (Constant _) = True
423+ isCon _ = False
424+
420425 conType (DCon _ _ _) = True
421426 conType (TCon _ _) = True
422427 conType _ = False
423428
424429checkRec tm (P Bound y _)
425− | (P xt _ _, _) <- unApply tm,
426− conType xt = do nmap <- get
427− case lookup y nmap of
428− Nothing -> do put ((y, tm) : nmap)
429− return True
430− Just x' -> checkRec tm x'
430+ | isCon tm = do nmap <- get
431+ case lookup y nmap of
432+ Nothing -> do put ((y, tm) : nmap)
433+ return True
434+ Just x' -> checkRec tm x'
431435 where
436+ isCon tm
437+ | (P yt _ _, _) <- unApply tm,
438+ conType yt = True
439+ isCon (Constant _) = True
440+ isCon _ = False
441+
432442 conType (DCon _ _ _) = True
433443 conType (TCon _ _) = True
434444 conType _ = False
435445
436446checkRec (App _ f a) p@(P _ _ _) = checkRec f p
447+checkRec (App _ f a) p@(Constant _) = checkRec f p
437448checkRec p@(P _ _ _) (App _ f a) = checkRec p f
449+checkRec p@(Constant _) (App _ f a) = checkRec p f
438450checkRec fa@(App _ _ _) fa'@(App _ _ _)
439451 | (f, as) <- unApply fa,
440452 (f', as') <- unApply fa'
@@ -454,6 +466,7 @@ checkRec fa@(App _ _ _) fa'@(App _ _ _)
454466 return (aok && asok)
455467 conType (P (DCon _ _ _) _ _) = True
456468 conType (P (TCon _ _) _ _) = True
469+ conType (Constant _) = True
457470 conType _ = False
458471
459472checkRec (P xt x _) (P yt y _)
@@ -469,4 +482,8 @@ checkRec (P xt x _) (P yt y _)
469482 | Bound <- x = True
470483 | Bound <- y = True
471484 | otherwise = False -- name is different, unrecoverable
485+-- A function reference against a constant might be recoverable if we get to
486+-- reduce the function
487+checkRec (P Ref _ _) (Constant _) = return True
488+checkRec (Constant _) (P Ref _ _) = return True
472489checkRec _ _ = return False
src/Idris/Elab/Clause.hs+1−1
@@ -836,7 +836,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
836836
837837 let rhs' = rhsElab
838838
839− when (not (null defer)) $ logElab 1 $ "DEFERRED " ++
839+ when (not (null defer)) $ logElab 2 $ "DEFERRED " ++
840840 show (map (\ (n, (_,_,t,_)) -> (n, t)) defer)
841841
842842 -- If there's holes, set the metavariables as undefinable
src/Idris/IBC.hs+12−12
@@ -223,7 +223,7 @@ writeArchive fp i = do let a = L.foldl (\x y -> addEntryToArchive y x) emptyArch
223223writeIBC :: FilePath -> FilePath -> Idris ()
224224writeIBC src f
225225 = do
226− logIBC 1 $ "Writing IBC for: " ++ show f
226+ logIBC 2 $ "Writing IBC for: " ++ show f
227227 iReport 2 $ "Writing IBC for: " ++ show f
228228 i <- getIState
229229-- case (Data.List.map fst (idris_metavars i)) \\ primDefs of
@@ -233,8 +233,8 @@ writeIBC src f
233233 ibcf <- mkIBC (ibc_write i) (initIBC { sourcefile = src })
234234 idrisCatch (do runIO $ createDirectoryIfMissing True (dropFileName f)
235235 writeArchive f ibcf
236− logIBC 1 "Written")
237− (\c -> do logIBC 1 $ "Failed " ++ pshow i c)
236+ logIBC 2 "Written")
237+ (\c -> do logIBC 2 $ "Failed " ++ pshow i c)
238238 return ()
239239
240240-- | Write a package index containing all the imports in the current
@@ -244,14 +244,14 @@ writePkgIndex :: FilePath -> Idris ()
244244writePkgIndex f
245245 = do i <- getIState
246246 let imps = map (\ (x, y) -> (True, x)) $ idris_imported i
247− logIBC 1 $ "Writing package index " ++ show f ++ " including\n" ++
247+ logIBC 2 $ "Writing package index " ++ show f ++ " including\n" ++
248248 show (map snd imps)
249249 resetNameIdx
250250 let ibcf = initIBC { ibc_imports = imps }
251251 idrisCatch (do runIO $ createDirectoryIfMissing True (dropFileName f)
252252 writeArchive f ibcf
253− logIBC 1 "Written")
254− (\c -> do logIBC 1 $ "Failed " ++ pshow i c)
253+ logIBC 2 "Written")
254+ (\c -> do logIBC 2 $ "Failed " ++ pshow i c)
255255 return ()
256256
257257mkIBC :: [IBCWrite] -> IBCFile -> Idris IBCFile
@@ -369,7 +369,7 @@ process :: Bool -- ^ Reexporting
369369process reexp phase archive fn = do
370370 ver <- getEntry 0 "ver" archive
371371 when (ver /= ibcVersion) $ do
372− logIBC 1 "ibc out of date"
372+ logIBC 2 "ibc out of date"
373373 let e = if ver < ibcVersion
374374 then "an earlier" else "a later"
375375 ldir <- runIO $ getIdrisLibDir
@@ -524,10 +524,10 @@ processImports reexp phase ar = do
524524 p -> p
525525 case fp of
526526 LIDR fn -> do
527− logIBC 1 $ "Failed at " ++ fn
527+ logIBC 2 $ "Failed at " ++ fn
528528 ifail "Must be an ibc"
529529 IDR fn -> do
530− logIBC 1 $ "Failed at " ++ fn
530+ logIBC 2 $ "Failed at " ++ fn
531531 ifail "Must be an ibc"
532532 IBC fn src -> loadIBC (reexp && re) phase' fn) fs
533533
@@ -650,7 +650,7 @@ processDefs ar = do
650650 case d' of
651651 TyDecl _ _ -> return ()
652652 _ -> do
653− logIBC 1 $ "SOLVING " ++ show n
653+ logIBC 2 $ "SOLVING " ++ show n
654654 solveDeferred emptyFC n
655655 updateIState (\i -> i { tt_ctxt = addCtxtDef n d' (tt_ctxt i) })) ds
656656 where
@@ -749,9 +749,9 @@ processAccess reexp phase ar = do
749749
750750 if (not reexp)
751751 then do
752− logIBC 1 $ "Not exporting " ++ show n
752+ logIBC 2 $ "Not exporting " ++ show n
753753 setAccessibility n Hidden
754− else logIBC 1 $ "Exporting " ++ show n
754+ else logIBC 2 $ "Exporting " ++ show n
755755 -- Everything should be available at the REPL from
756756 -- things imported publicly
757757 when (phase == IBC_REPL True) $ setAccessibility n Public) ds
src/Idris/Termination.hs+2−2
@@ -284,8 +284,8 @@ buildSCG (_, n) = do
284284
285285delazy = delazy' False -- not lazy codata
286286delazy' all t@(App _ f a)
287− | (P _ (UN l) _, [_, _, arg]) <- unApply t,
288− l == txt "Force" = delazy' all arg
287+ | (P _ (UN l) _, [P _ (UN lty) _, _, arg]) <- unApply t,
288+ l == txt "Force" && (all || lty /= txt "Infinite") = delazy' all arg
289289 | (P _ (UN l) _, [P _ (UN lty) _, _, arg]) <- unApply t,
290290 l == txt "Delay" && (all || lty /= txt "Infinite") = delazy arg
291291 | (P _ (UN l) _, [P _ (UN lty) _, arg]) <- unApply t,
test/TestData.hs+2−1
@@ -290,7 +290,8 @@ testFamiliesData = [
290290 ( 19, ANY ),
291291 ( 20, ANY ),
292292 ( 21, ANY ),
293− ( 22, ANY )]),
293+ ( 22, ANY ),
294+ ( 23, ANY )]),
294295 ("tutorial", "Tutorial examples",
295296 [ ( 1, ANY ),
296297 ( 2, ANY ),
test/regression002/Canonicity.idrnew file+13
@@ -0,0 +1,13 @@
1+module Canonicity
2+%default total
3+
4+data ZeroSumList : Integer -> Type where
5+ Cons : (m : Integer) -> ZeroSumList n -> ZeroSumList (m + n)
6+ Nil : ZeroSumList 0
7+
8+f : ZeroSumList 0 -> Nat
9+f Nil = 0
10+
11+NaN : Nat
12+NaN = f (Cons 0 Nil)
13+
test/regression002/expected+2
@@ -145,3 +145,5 @@ When checking argument value to function Prelude.Basics.the:
145145 -0.0
146146 and
147147 0.0
148+Canonicity.idr:9:1:Canonicity.f is not total as there are missing cases
149+Canonicity.idr:12:1:Canonicity.NaN is possibly not total due to: Canonicity.f
test/regression002/run+1
@@ -32,6 +32,7 @@ ${IDRIS:-idris} $@ --nobanner --nocolour --quiet --port none <<!
3232:load reg076.idr
3333:load reg077.idr
3434:load DoubleEquality.idr
35+:load Canonicity.idr
3536!
3637
3738rm -f *.ibc
test/totality023/expectednew file+2
@@ -0,0 +1,2 @@
1+totality023.idr:9:1:
2+Main.run is possibly not total due to recursive path Main.run --> Main.run
test/totality023/runnew file+3
@@ -0,0 +1,3 @@
1+#!/usr/bin/env bash
2+${IDRIS:-idris} $@ totality023.idr --check
3+rm -f *.ibc
test/totality023/totality023.idrnew file+11
@@ -0,0 +1,11 @@
1+data InfIO : Type where
2+ Do : IO a -> (a -> Inf InfIO) -> InfIO
3+
4+foo : InfIO
5+foo = Do (putStr "Foo") (\x => foo)
6+
7+total
8+run : InfIO -> IO ()
9+run (Do x f) = do r <- x
10+ run (f r)
11+