@@ -111,6 +111,7 @@ data IState = IState {
111 idris_metavars :: [(Name, (Maybe Name, Int, Bool))], -- ^ The currently defined but not proven metavariables
111 idris_metavars :: [(Name, (Maybe Name, Int, Bool))], -- ^ The currently defined but not proven metavariables
112 idris_coercions :: [Name],
112 idris_coercions :: [Name],
113 idris_transforms :: [(Term, Term)],
113 idris_transforms :: [(Term, Term)],
114+ idris_errRev :: [(Term, Term)],
114 syntax_rules :: [Syntax],
115 syntax_rules :: [Syntax],
115 syntax_keywords :: [String],
116 syntax_keywords :: [String],
116 imported :: [FilePath], -- ^ The imported modules
117 imported :: [FilePath], -- ^ The imported modules
@@ -187,6 +188,7 @@ data IBCWrite = IBCFix FixDecl
187 | IBCTotal Name Totality
188 | IBCTotal Name Totality
188 | IBCFlags Name [FnOpt]
189 | IBCFlags Name [FnOpt]
189 | IBCTrans (Term, Term)
190 | IBCTrans (Term, Term)
191+ | IBCErrRev (Term, Term)
190 | IBCCG Name
192 | IBCCG Name
191 | IBCDoc Name
193 | IBCDoc Name
192 | IBCCoercion Name
194 | IBCCoercion Name
@@ -203,7 +205,7 @@ idrisInit = IState initContext [] [] emptyContext emptyContext emptyContext
203 emptyContext emptyContext emptyContext emptyContext
205 emptyContext emptyContext emptyContext emptyContext
204 emptyContext emptyContext emptyContext emptyContext
206 emptyContext emptyContext emptyContext emptyContext
205 emptyContext
207 emptyContext
206− [] [] defaultOpts 6 [] [] [] [] [] [] [] [] [] [] [] []
208+ [] [] defaultOpts 6 [] [] [] [] [] [] [] [] [] [] [] [] []
207 [] Nothing Nothing [] [] [] Hidden False [] Nothing [] [] RawOutput
209 [] Nothing Nothing [] [] [] Hidden False [] Nothing [] [] RawOutput
208 True defaultTheme stdout [] (0, emptyContext) emptyContext
210 True defaultTheme stdout [] (0, emptyContext) emptyContext
@@ -357,33 +359,36 @@ deriving instance NFData Static
359-- Mark bindings with their explicitness, and laziness
361-- Mark bindings with their explicitness, and laziness
360−data Plicity = Imp { plazy :: Bool,
362+data Plicity = Imp { pargopts :: [ArgOpt],
361 pstatic :: Static,
363 pstatic :: Static,
362 pdocstr :: String,
364 pdocstr :: String,
363 pparam :: Bool }
365 pparam :: Bool }
364− | Exp { plazy :: Bool,
366+ | Exp { pargopts :: [ArgOpt],
365 pstatic :: Static,
367 pstatic :: Static,
366 pdocstr :: String,
368 pdocstr :: String,
367 pparam :: Bool }
369 pparam :: Bool }
368− | Constraint { plazy :: Bool,
370+ | Constraint { pargopts :: [ArgOpt],
369 pstatic :: Static,
371 pstatic :: Static,
370 pdocstr :: String }
372 pdocstr :: String }
371− | TacImp { plazy :: Bool,
373+ | TacImp { pargopts :: [ArgOpt],
372 pstatic :: Static,
374 pstatic :: Static,
373 pscript :: PTerm,
375 pscript :: PTerm,
374 pdocstr :: String }
376 pdocstr :: String }
375 deriving (Show, Eq)
377 deriving (Show, Eq)
379+plazy :: Plicity -> Bool
380+plazy tm = Lazy `elem` pargopts tm
378deriving instance Binary Plicity
383deriving instance Binary Plicity
379deriving instance NFData Plicity
384deriving instance NFData Plicity
382−impl = Imp False Dynamic "" False
387+impl = Imp [Lazy] Dynamic "" False
383−expl = Exp False Dynamic "" False
388+expl = Exp [] Dynamic "" False
384−expl_param = Exp False Dynamic "" True
389+expl_param = Exp [] Dynamic "" True
385−constraint = Constraint False Dynamic ""
390+constraint = Constraint [] Dynamic ""
386−tacimpl t = TacImp False Dynamic t ""
391+tacimpl t = TacImp [] Dynamic t ""
388data FnOpt = Inlinable -- always evaluate when simplifying
393data FnOpt = Inlinable -- always evaluate when simplifying
389 | TotalFn | PartialFn
394 | TotalFn | PartialFn
@@ -393,6 +398,7 @@ data FnOpt = Inlinable -- always evaluate when simplifying
393 | Implicit -- implicit coercion
398 | Implicit -- implicit coercion
394 | CExport String -- export, with a C name
399 | CExport String -- export, with a C name
395 | ErrorHandler -- ^^ an error handler for use with the ErrorReflection extension
400 | ErrorHandler -- ^^ an error handler for use with the ErrorReflection extension
401+ | ErrorReverse -- ^^ attempt to reverse normalise before showing in error
396 | Reflection -- a reflecting function, compile-time only
402 | Reflection -- a reflecting function, compile-time only
397 | Specialise [(Name, Maybe Int)] -- specialise it, freeze these names
403 | Specialise [(Name, Maybe Int)] -- specialise it, freeze these names
398 deriving (Show, Eq)
404 deriving (Show, Eq)
@@ -413,6 +419,7 @@ dictionary = elem Dictionary
413-- | Data declaration options
419-- | Data declaration options
414data DataOpt = Codata -- Set if the the data-type is coinductive
420data DataOpt = Codata -- Set if the the data-type is coinductive
415 | DefaultEliminator -- Set if an eliminator should be generated for data type
421 | DefaultEliminator -- Set if an eliminator should be generated for data type
416 deriving (Show, Eq)
423 deriving (Show, Eq)
418type DataOpts = [DataOpt]
425type DataOpts = [DataOpt]
@@ -729,21 +736,31 @@ type PDo = PDo' PTerm
730data PArg' t = PImp { priority :: Int,
737data PArg' t = PImp { priority :: Int,
731 machine_inf :: Bool, -- true if the machine inferred it
738 machine_inf :: Bool, -- true if the machine inferred it
739+ argopts :: [ArgOpt],
732− lazyarg :: Bool, pname :: Name, getTm :: t,
740+ pname :: Name, getTm :: t,
733 pargdoc :: String }
741 pargdoc :: String }
734 | PExp { priority :: Int,
742 | PExp { priority :: Int,
743+ argopts :: [ArgOpt],
735− lazyarg :: Bool, getTm :: t,
744+ getTm :: t,
736 pargdoc :: String }
745 pargdoc :: String }
737 | PConstraint { priority :: Int,
746 | PConstraint { priority :: Int,
747+ argopts :: [ArgOpt],
738− lazyarg :: Bool, getTm :: t,
748+ getTm :: t,
739 pargdoc :: String }
749 pargdoc :: String }
740 | PTacImplicit { priority :: Int,
750 | PTacImplicit { priority :: Int,
751+ argopts :: [ArgOpt],
741− lazyarg :: Bool, pname :: Name,
752+ pname :: Name,
742 getScript :: t,
753 getScript :: t,
743 getTm :: t,
754 getTm :: t,
744 pargdoc :: String }
755 pargdoc :: String }
745 deriving (Show, Eq, Functor)
756 deriving (Show, Eq, Functor)
758+data ArgOpt = Lazy | HideDisplay
761+lazyarg :: PArg' t -> Bool
762+lazyarg tm = Lazy `elem` argopts tm
747instance Sized a => Sized (PArg' a) where
764instance Sized a => Sized (PArg' a) where
748 size (PImp p _ l nm trm _) = 1 + size nm + size trm
765 size (PImp p _ l nm trm _) = 1 + size nm + size trm
749 size (PExp p l trm _) = 1 + size trm
766 size (PExp p l trm _) = 1 + size trm
@@ -755,10 +772,10 @@ deriving instance Binary PArg'
755deriving instance NFData PArg'
772deriving instance NFData PArg'
758−pimp n t mach = PImp 1 mach True n t ""
775+pimp n t mach = PImp 1 mach [Lazy] n t ""
759−pexp t = PExp 1 False t ""
776+pexp t = PExp 1 [] t ""
760−pconst t = PConstraint 1 False t ""
777+pconst t = PConstraint 1 [] t ""
761−ptacimp n s t = PTacImplicit 2 True n s t ""
778+ptacimp n s t = PTacImplicit 2 [Lazy] n s t ""
763type PArg = PArg' PTerm
780type PArg = PArg' PTerm
@@ -801,6 +818,7 @@ deriving instance NFData OptInfo
802data TypeInfo = TI { con_names :: [Name],
819data TypeInfo = TI { con_names :: [Name],
803 codata :: Bool,
820 codata :: Bool,
821+ data_opts :: DataOpts,
804 param_pos :: [Int] }
822 param_pos :: [Int] }
805 deriving Show
823 deriving Show
@@ -1008,7 +1026,7 @@ prettyImp impl = prettySe 10
1008 prettySe 10 sc
1026 prettySe 10 sc
1009 prettySe p (PPi (Exp l s _ _) n ty sc)
1027 prettySe p (PPi (Exp l s _ _) n ty sc)
1010 | n `elem` allNamesIn sc || impl =
1028 | n `elem` allNamesIn sc || impl =
1011− let open = if l then text "|" <> lparen else lparen in
1029+ let open = if Lazy `elem` l then text "|" <> lparen else lparen in
1012 bracket p 2 $
1030 bracket p 2 $
1013 if size sc > breakingSize then
1031 if size sc > breakingSize then
1014 open <> pretty n <+> colon <+> prettySe 10 ty <> rparen <+>
1032 open <> pretty n <+> colon <+> prettySe 10 ty <> rparen <+>
@@ -1029,7 +1047,7 @@ prettyImp impl = prettySe 10
1029 _ -> empty
1047 _ -> empty
1030 prettySe p (PPi (Imp l s _ _) n ty sc)
1048 prettySe p (PPi (Imp l s _ _) n ty sc)
1031 | impl =
1049 | impl =
1032− let open = if l then text "|" <> lbrace else lbrace in
1050+ let open = if Lazy `elem` l then text "|" <> lbrace else lbrace in
1033 bracket p 2 $
1051 bracket p 2 $
1034 if size sc > breakingSize then
1052 if size sc > breakingSize then
1035 open <> pretty n <+> colon <+> prettySe 10 ty <> rbrace <+>
1053 open <> pretty n <+> colon <+> prettySe 10 ty <> rbrace <+>
@@ -1222,7 +1240,7 @@ showImp ist impl colour tm = se 10 [] tm where
1222 se p bnd (PPi (Exp l s _ param) n ty sc)
1240 se p bnd (PPi (Exp l s _ param) n ty sc)
1223 | n `elem` allNamesIn sc || impl
1241 | n `elem` allNamesIn sc || impl
1224 = bracket p 2 $
1242 = bracket p 2 $
1225− (if l then "|(" else "(") ++
1243+ (if Lazy `elem` l then "|(" else "(") ++
1226 perhapsColourise colouriseBound (show n) ++ " : " ++ se 10 bnd ty ++
1244 perhapsColourise colouriseBound (show n) ++ " : " ++ se 10 bnd ty ++
1228 (if (impl && param) then "P" else "") ++
1246 (if (impl && param) then "P" else "") ++
@@ -1233,7 +1251,7 @@ showImp ist impl colour tm = se 10 [] tm where
1233 Static -> "[static] "
1251 Static -> "[static] "
1235 se p bnd (PPi (Imp l s _ _) n ty sc)
1253 se p bnd (PPi (Imp l s _ _) n ty sc)
1236− | impl = bracket p 2 $ (if l then "|{" else "{") ++
1254+ | impl = bracket p 2 $ (if Lazy `elem` l then "|{" else "{") ++
1237 perhapsColourise colouriseBound (show n) ++ " : " ++ se 10 bnd ty ++
1255 perhapsColourise colouriseBound (show n) ++ " : " ++ se 10 bnd ty ++
1238 "} " ++ st ++ "-> " ++ se 10 ((n, True):bnd) sc
1256 "} " ++ st ++ "-> " ++ se 10 ((n, True):bnd) sc
1239 | otherwise = se 10 ((n, True):bnd) sc
1257 | otherwise = se 10 ((n, True):bnd) sc
@@ -1247,6 +1265,9 @@ showImp ist impl colour tm = se 10 [] tm where
1247 "{tacimp " ++ (perhapsColourise colouriseBound (show n)) ++ " : " ++ se 10 bnd ty ++ "} -> " ++
1265 "{tacimp " ++ (perhapsColourise colouriseBound (show n)) ++ " : " ++ se 10 bnd ty ++ "} -> " ++
1248 se 10 ((n, False):bnd) sc
1266 se 10 ((n, False):bnd) sc
1249 se p bnd (PMatchApp _ f) = "match " ++ show f
1267 se p bnd (PMatchApp _ f) = "match " ++ show f
1268+ se p bnd (PApp _ hd@(PRef fc f) [tm])
1269+ | PConstant (Idris.Core.TT.Str str) <- getTm tm,
1270+ f == sUN "Symbol_" = "'" ++ se 10 bnd (PRef fc (sUN str))
1250 se p bnd (PApp _ hd@(PRef _ f) [])
1271 se p bnd (PApp _ hd@(PRef _ f) [])
1251 | not impl = se p bnd hd
1272 | not impl = se p bnd hd
1252 se p bnd (PAppBind _ hd@(PRef _ f) [])
1273 se p bnd (PAppBind _ hd@(PRef _ f) [])