@@ -48,23 +48,24 @@ import Text.PrettyPrint.Annotated.Leijen
48data ElabWhat = ETypes | EDefns | EAll
48data ElabWhat = ETypes | EDefns | EAll
49 deriving (Show, Eq)
49 deriving (Show, Eq)
51−-- Data to pass to recursively called elaborators; e.g. for where blocks,
51+-- | Data to pass to recursively called elaborators; e.g. for where blocks,
52-- paramaterised declarations, etc.
52-- paramaterised declarations, etc.
54-- rec_elabDecl is used to pass the top level elaborator into other elaborators,
54-- rec_elabDecl is used to pass the top level elaborator into other elaborators,
55-- so that we can have mutually recursive elaborators in separate modules without
55-- so that we can have mutually recursive elaborators in separate modules without
56-- having to muck about with cyclic modules.
56-- having to muck about with cyclic modules.
57−data ElabInfo = EInfo { params :: [(Name, PTerm)],
57+data ElabInfo = EInfo {
58+ params :: [(Name, PTerm)]
58− inblock :: Ctxt [Name], -- names in the block, and their params
59+ , inblock :: Ctxt [Name] -- ^ names in the block, and their params
59− liftname :: Name -> Name,
60+ , liftname :: Name -> Name
60− namespace :: Maybe [String],
61+ , namespace :: Maybe [String]
61− elabFC :: Maybe FC,
62+ , elabFC :: Maybe FC
62− -- We may, recursively, collect transformations to
64+ -- | We may, recursively, collect transformations to do on the rhs,
63− -- do on the rhs, e.g. rewriting recursive calls to
65+ -- e.g. rewriting recursive calls to functions defined by 'with'
64− -- functions defined by 'with'
65− rhs_trans :: PTerm -> PTerm,
66+ , rhs_trans :: PTerm -> PTerm
66− rec_elabDecl :: ElabWhat -> ElabInfo -> PDecl ->
67+ , rec_elabDecl :: ElabWhat -> ElabInfo -> PDecl -> Idris ()
69toplevel :: ElabInfo
70toplevel :: ElabInfo
70toplevel = EInfo [] emptyContext id Nothing Nothing id (\_ _ _ -> fail "Not implemented")
71toplevel = EInfo [] emptyContext id Nothing Nothing id (\_ _ _ -> fail "Not implemented")
@@ -90,13 +91,13 @@ data IOption = IOption {
90 , opt_importdirs :: [FilePath]
91 , opt_importdirs :: [FilePath]
91 , opt_triple :: String
92 , opt_triple :: String
92 , opt_cpu :: String
93 , opt_cpu :: String
93− , opt_cmdline :: [Opt] -- remember whole command line
94+ , opt_cmdline :: [Opt] -- ^ remember whole command line
94 , opt_origerr :: Bool
95 , opt_origerr :: Bool
95 , opt_autoSolve :: Bool -- ^ automatically apply "solve" tactic in prover
96 , opt_autoSolve :: Bool -- ^ automatically apply "solve" tactic in prover
96− , opt_autoImport :: [FilePath] -- ^ e.g. Builtins+Prelude
97+ , opt_autoImport :: [FilePath] -- ^ List of modules to auto import i.e. `Builtins+Prelude`
97 , opt_optimise :: [Optimisation]
98 , opt_optimise :: [Optimisation]
98 , opt_printdepth :: Maybe Int
99 , opt_printdepth :: Maybe Int
99− , opt_evaltypes :: Bool -- ^ normalise types in :t
100+ , opt_evaltypes :: Bool -- ^ normalise types in `:t`
100 , opt_desugarnats :: Bool
101 , opt_desugarnats :: Bool
101 , opt_autoimpls :: Bool
102 , opt_autoimpls :: Bool
102 } deriving (Show, Eq)
103 } deriving (Show, Eq)
@@ -130,39 +131,43 @@ defaultOpts = IOption { opt_logLevel = 0
132data PPOption = PPOption {
133data PPOption = PPOption {
133− ppopt_impl :: Bool -- ^^ whether to show implicits
134+ ppopt_impl :: Bool -- ^ whether to show implicits
134 , ppopt_desugarnats :: Bool
135 , ppopt_desugarnats :: Bool
135− , ppopt_pinames :: Bool -- ^^ whether to show names in pi bindings
136+ , ppopt_pinames :: Bool -- ^ whether to show names in pi bindings
136− , ppopt_depth :: Maybe Int
137+ , ppopt_depth :: Maybe Int
137−} deriving (Show)
138+ } deriving (Show)
139−data Optimisation = PETransform -- partial eval and associated transforms
140+data Optimisation = PETransform -- ^ partial eval and associated transforms
140 deriving (Show, Eq)
141 deriving (Show, Eq)
142defaultOptimise = [PETransform]
143defaultOptimise = [PETransform]
144-- | Pretty printing options with default verbosity.
145-- | Pretty printing options with default verbosity.
145defaultPPOption :: PPOption
146defaultPPOption :: PPOption
146−defaultPPOption = PPOption { ppopt_impl = False,
147+defaultPPOption = PPOption {
147− ppopt_desugarnats = False,
149+ , ppopt_desugarnats = False
148− ppopt_pinames = False,
150+ , ppopt_pinames = False
149− ppopt_depth = Just 200 }
151+ , ppopt_depth = Just 200
151-- | Pretty printing options with the most verbosity.
154-- | Pretty printing options with the most verbosity.
152verbosePPOption :: PPOption
155verbosePPOption :: PPOption
153−verbosePPOption = PPOption { ppopt_impl = True,
156+verbosePPOption = PPOption {
154− ppopt_desugarnats = True,
158+ , ppopt_desugarnats = True
155− ppopt_pinames = True,
159+ , ppopt_pinames = True
156− ppopt_depth = Just 200 }
160+ , ppopt_depth = Just 200
158-- | Get pretty printing options from the big options record.
163-- | Get pretty printing options from the big options record.
159ppOption :: IOption -> PPOption
164ppOption :: IOption -> PPOption
160ppOption opt = PPOption {
165ppOption opt = PPOption {
161− ppopt_impl = opt_showimp opt,
166+ ppopt_impl = opt_showimp opt
162− ppopt_pinames = False,
167+ , ppopt_pinames = False
163− ppopt_depth = opt_printdepth opt,
168+ , ppopt_depth = opt_printdepth opt
164− ppopt_desugarnats = opt_desugarnats opt
169+ , ppopt_desugarnats = opt_desugarnats opt
167-- | Get pretty printing options from an idris state record.
172-- | Get pretty printing options from an idris state record.
168ppOptionIst :: IState -> PPOption
173ppOptionIst :: IState -> PPOption
@@ -171,13 +176,13 @@ ppOptionIst = ppOption . idris_options
171data LanguageExt = TypeProviders | ErrorReflection deriving (Show, Eq, Read, Ord)
176data LanguageExt = TypeProviders | ErrorReflection deriving (Show, Eq, Read, Ord)
173-- | The output mode in use
178-- | The output mode in use
174−data OutputMode = RawOutput Handle -- ^ Print user output directly to the handle
179+data OutputMode = RawOutput Handle -- ^ Print user output directly to the handle
175 | IdeMode Integer Handle -- ^ Send IDE output for some request ID to the handle
180 | IdeMode Integer Handle -- ^ Send IDE output for some request ID to the handle
176 deriving Show
181 deriving Show
178-- | How wide is the console?
183-- | How wide is the console?
179data ConsoleWidth = InfinitelyWide -- ^ Have pretty-printer assume that lines should not be broken
184data ConsoleWidth = InfinitelyWide -- ^ Have pretty-printer assume that lines should not be broken
180− | ColsWide Int -- ^ Manually specified - must be positive
185+ | ColsWide Int -- ^ Manually specified - must be positive
181 | AutomaticWidth -- ^ Attempt to determine width, or 80 otherwise
186 | AutomaticWidth -- ^ Attempt to determine width, or 80 otherwise
182 deriving (Show, Eq)
187 deriving (Show, Eq)
@@ -189,97 +194,105 @@ data DefaultTotality = DefaultCheckingTotal -- ^ Total
190-- | The global state used in the Idris monad
195-- | The global state used in the Idris monad
191data IState = IState {
196data IState = IState {
192− tt_ctxt :: Context, -- ^ All the currently defined names and their terms
197+ tt_ctxt :: Context -- ^ All the currently defined names and their terms
193− idris_constraints :: S.Set ConstraintFC,
194− -- ^ A list of universe constraints and their corresponding source locations
198+ , idris_constraints :: S.Set ConstraintFC -- ^ A list of universe constraints and their corresponding source locations
195− idris_infixes :: [FixDecl], -- ^ Currently defined infix operators
199+ , idris_infixes :: [FixDecl] -- ^ Currently defined infix operators
196− idris_implicits :: Ctxt [PArg],
200+ , idris_implicits :: Ctxt [PArg]
197− idris_statics :: Ctxt [Bool],
201+ , idris_statics :: Ctxt [Bool]
198− idris_classes :: Ctxt ClassInfo,
202+ , idris_classes :: Ctxt ClassInfo
199− idris_openimpls :: [Name], -- ^ Privileged implementations, will resolve immediately
203+ , idris_openimpls :: [Name] -- ^ Privileged implementations, will resolve immediately
200− idris_records :: Ctxt RecordInfo,
204+ , idris_records :: Ctxt RecordInfo
201− idris_dsls :: Ctxt DSL,
205+ , idris_dsls :: Ctxt DSL
202− idris_optimisation :: Ctxt OptInfo,
206+ , idris_optimisation :: Ctxt OptInfo
203− idris_datatypes :: Ctxt TypeInfo,
207+ , idris_datatypes :: Ctxt TypeInfo
204− idris_namehints :: Ctxt [Name],
208+ , idris_namehints :: Ctxt [Name]
205− idris_patdefs :: Ctxt ([([(Name, Term)], Term, Term)], [PTerm]), -- not exported
209+
206− -- ^ list of lhs/rhs, and a list of missing clauses
210+ -- | list of lhs/rhs, and a list of missing clauses. These are not
212+ , idris_patdefs :: Ctxt ([([(Name, Term)], Term, Term)], [PTerm])
207− idris_flags :: Ctxt [FnOpt],
213+ , idris_flags :: Ctxt [FnOpt]
208− idris_callgraph :: Ctxt CGInfo, -- name, args used in each pos
214+ , idris_callgraph :: Ctxt CGInfo -- ^ name, args used in each pos
209− idris_docstrings :: Ctxt (Docstring DocTerm, [(Name, Docstring DocTerm)]),
215+ , idris_docstrings :: Ctxt (Docstring DocTerm, [(Name, Docstring DocTerm)])
210− idris_moduledocs :: Ctxt (Docstring DocTerm),
216+
211− -- ^ module documentation is saved in a special MN so the context
217+ -- | module documentation is saved in a special MN so the context
212− -- mechanism can be used for disambiguation
218+ -- mechanism can be used for disambiguation.
219+ , idris_moduledocs :: Ctxt (Docstring DocTerm)
213− idris_tyinfodata :: Ctxt TIData,
220+ , idris_tyinfodata :: Ctxt TIData
214− idris_fninfo :: Ctxt FnInfo,
221+ , idris_fninfo :: Ctxt FnInfo
215− idris_transforms :: Ctxt [(Term, Term)],
222+ , idris_transforms :: Ctxt [(Term, Term)]
216− idris_autohints :: Ctxt [Name],
223+ , idris_autohints :: Ctxt [Name]
217− idris_totcheck :: [(FC, Name)], -- names to check totality on
224+ , idris_totcheck :: [(FC, Name)] -- ^ names to check totality on
218− idris_defertotcheck :: [(FC, Name)], -- names to check at the end
225+ , idris_defertotcheck :: [(FC, Name)] -- ^ names to check at the end
219− idris_totcheckfail :: [(FC, String)],
226+ , idris_totcheckfail :: [(FC, String)]
220− idris_options :: IOption,
227+ , idris_options :: IOption
221− idris_name :: Int,
228+ , idris_name :: Int
222− idris_lineapps :: [((FilePath, Int), PTerm)],
229+ , idris_lineapps :: [((FilePath, Int), PTerm)] -- ^ Full application LHS on source line
223− -- ^ Full application LHS on source line
230+
224− idris_metavars :: [(Name, (Maybe Name, Int, [Name], Bool, Bool))],
225− -- ^ The currently defined but not proven metavariables. The Int
231+ -- | The currently defined but not proven metavariables. The Int is
226− -- is the number of vars to display as a context, the Maybe Name
232+ -- the number of vars to display as a context, the Maybe Name is its
227− -- is its top-level function, the [Name] is the list of local variables
233+ -- top-level function, the [Name] is the list of local variables
228− -- available for proof search and the Bools are whether :p is
234+ -- available for proof search and the Bools are whether :p is
229− -- allowed, and whether the variable is definable at all
235+ -- allowed, and whether the variable is definable at all
230− -- (Metavariables are not definable if they are applied in a term which
236+ -- (Metavariables are not definable if they are applied in a term
231− -- still has hole bindings)
237+ -- which still has hole bindings)
238+ , idris_metavars :: [(Name, (Maybe Name, Int, [Name], Bool, Bool))]
232− idris_coercions :: [Name],
239+ , idris_coercions :: [Name]
233− idris_errRev :: [(Term, Term)],
240+ , idris_errRev :: [(Term, Term)]
234− syntax_rules :: SyntaxRules,
241+ , syntax_rules :: SyntaxRules
235− syntax_keywords :: [String],
242+ , syntax_keywords :: [String]
236− imported :: [FilePath], -- ^ The imported modules
243+ , imported :: [FilePath] -- ^ The imported modules
237− idris_scprims :: [(Name, (Int, PrimFn))],
244+ , idris_scprims :: [(Name, (Int, PrimFn))]
238− idris_objs :: [(Codegen, FilePath)],
245+ , idris_objs :: [(Codegen, FilePath)]
239− idris_libs :: [(Codegen, String)],
246+ , idris_libs :: [(Codegen, String)]
240− idris_cgflags :: [(Codegen, String)],
247+ , idris_cgflags :: [(Codegen, String)]
241− idris_hdrs :: [(Codegen, String)],
248+ , idris_hdrs :: [(Codegen, String)]
242− idris_imported :: [(FilePath, Bool)], -- ^ Imported ibc file names, whether public
249+ , idris_imported :: [(FilePath, Bool)] -- ^ Imported ibc file names, whether public
243− proof_list :: [(Name, (Bool, [String]))],
250+ , proof_list :: [(Name, (Bool, [String]))]
244− errSpan :: Maybe FC,
251+ , errSpan :: Maybe FC
245− parserWarnings :: [(FC, Err)],
252+ , parserWarnings :: [(FC, Err)]
246− lastParse :: Maybe Name,
253+ , lastParse :: Maybe Name
247− indent_stack :: [Int],
254+ , indent_stack :: [Int]
248− brace_stack :: [Maybe Int],
255+ , brace_stack :: [Maybe Int]
249− lastTokenSpan :: Maybe FC, -- ^ What was the span of the latest token parsed?
256+ , lastTokenSpan :: Maybe FC -- ^ What was the span of the latest token parsed?
250− idris_parsedSpan :: Maybe FC,
257+ , idris_parsedSpan :: Maybe FC
251− hide_list :: Ctxt Accessibility,
258+ , hide_list :: Ctxt Accessibility
252− default_access :: Accessibility,
259+ , default_access :: Accessibility
253− default_total :: DefaultTotality,
260+ , default_total :: DefaultTotality
254− ibc_write :: [IBCWrite],
261+ , ibc_write :: [IBCWrite]
255− compiled_so :: Maybe String,
262+ , compiled_so :: Maybe String
256− idris_dynamic_libs :: [DynamicLib],
263+ , idris_dynamic_libs :: [DynamicLib]
257− idris_language_extensions :: [LanguageExt],
264+ , idris_language_extensions :: [LanguageExt]
258− idris_outputmode :: OutputMode,
265+ , idris_outputmode :: OutputMode
259− idris_colourRepl :: Bool,
266+ , idris_colourRepl :: Bool
260− idris_colourTheme :: ColourTheme,
267+ , idris_colourTheme :: ColourTheme
261− idris_errorhandlers :: [Name], -- ^ Global error handlers
268+ , idris_errorhandlers :: [Name] -- ^ Global error handlers
262− idris_nameIdx :: (Int, Ctxt (Int, Name)),
269+ , idris_nameIdx :: (Int, Ctxt (Int, Name))
263− idris_function_errorhandlers :: Ctxt (M.Map Name (S.Set Name)), -- ^ Specific error handlers
270+ , idris_function_errorhandlers :: Ctxt (M.Map Name (S.Set Name)) -- ^ Specific error handlers
264− module_aliases :: M.Map [T.Text] [T.Text],
271+ , module_aliases :: M.Map [T.Text] [T.Text]
265− idris_consolewidth :: ConsoleWidth, -- ^ How many chars wide is the console?
272+ , idris_consolewidth :: ConsoleWidth -- ^ How many chars wide is the console?
266− idris_postulates :: S.Set Name,
273+ , idris_postulates :: S.Set Name
267− idris_externs :: S.Set (Name, Int),
274+ , idris_externs :: S.Set (Name, Int)
268− idris_erasureUsed :: [(Name, Int)], -- ^ Function/constructor name, argument position is used
275+ , idris_erasureUsed :: [(Name, Int)] -- ^ Function/constructor name, argument position is used
269− idris_whocalls :: Maybe (M.Map Name [Name]),
276+ , idris_whocalls :: Maybe (M.Map Name [Name])
270− idris_callswho :: Maybe (M.Map Name [Name]),
277+ , idris_callswho :: Maybe (M.Map Name [Name])
271− idris_repl_defs :: [Name], -- ^ List of names that were defined in the repl, and can be re-/un-defined
279+ -- | List of names that were defined in the repl, and can be re-/un-defined
280+ , idris_repl_defs :: [Name]
272− elab_stack :: [(Name, Bool)], -- ^ Stack of names currently being elaborated, Bool set if it's an instance
282+ -- | Stack of names currently being elaborated, Bool set if it's an
273− -- (instances appear twice; also as a funtion name)
283+ -- instance (instances appear twice; also as a funtion name)
284+ , elab_stack :: [(Name, Bool)]
274− idris_symbols :: M.Map Name Name, -- ^ Symbol table (preserves sharing of names)
287+ , idris_symbols :: M.Map Name Name -- ^ Symbol table (preserves sharing of names)
275− idris_exports :: [Name], -- ^ Functions with ExportList
288+ , idris_exports :: [Name] -- ^ Functions with ExportList
276− idris_highlightedRegions :: [(FC, OutputAnnotation)], -- ^ Highlighting information to output
289+ , idris_highlightedRegions :: [(FC, OutputAnnotation)] -- ^ Highlighting information to output
277− idris_parserHighlights :: [(FC, OutputAnnotation)], -- ^ Highlighting information from the parser
290+ , idris_parserHighlights :: [(FC, OutputAnnotation)] -- ^ Highlighting information from the parser
278− idris_deprecated :: Ctxt String, -- ^ Deprecated names and explanation
291+ , idris_deprecated :: Ctxt String -- ^ Deprecated names and explanation
279− idris_inmodule :: S.Set Name, -- ^ Names defined in current module
292+ , idris_inmodule :: S.Set Name -- ^ Names defined in current module
280− idris_ttstats :: M.Map Term (Int, Term),
293+ , idris_ttstats :: M.Map Term (Int, Term)
281− idris_fragile :: Ctxt String -- ^ Fragile names and explanation.
294+ , idris_fragile :: Ctxt String -- ^ Fragile names and explanation.
284-- Required for parsers library, and therefore trifecta
297-- Required for parsers library, and therefore trifecta
285instance Show IState where
298instance Show IState where
@@ -295,20 +308,21 @@ deriving instance NFData SizeChange
295type SCGEntry = (Name, [Maybe (Int, SizeChange)])
308type SCGEntry = (Name, [Maybe (Int, SizeChange)])
296type UsageReason = (Name, Int) -- fn_name, its_arg_number
309type UsageReason = (Name, Int) -- fn_name, its_arg_number
298−data CGInfo = CGInfo { calls :: [Name],
311+data CGInfo = CGInfo {
299− scg :: [SCGEntry],
313+ , scg :: [SCGEntry]
300− usedpos :: [(Int, [UsageReason])]
314+ , usedpos :: [(Int, [UsageReason])]
302− deriving Show
315+ } deriving Show
304deriving instance Binary CGInfo
317deriving instance Binary CGInfo
305deriving instance NFData CGInfo
318deriving instance NFData CGInfo
308−primDefs = [sUN "unsafePerformPrimIO",
321+primDefs = [ sUN "unsafePerformPrimIO"
309− sUN "mkLazyForeignPrim",
322+ , sUN "mkLazyForeignPrim"
310− sUN "mkForeignPrim",
323+ , sUN "mkForeignPrim"
311− sUN "void"]
324+ , sUN "void"
313-- information that needs writing for the current module's .ibc file
327-- information that needs writing for the current module's .ibc file
314data IBCWrite = IBCFix FixDecl
328data IBCWrite = IBCFix FixDecl
@@ -323,7 +337,7 @@ data IBCWrite = IBCFix FixDecl
323 | IBCMetavar Name
337 | IBCMetavar Name
324 | IBCSyntax Syntax
338 | IBCSyntax Syntax
325 | IBCKeyword String
339 | IBCKeyword String
326− | IBCImport (Bool, FilePath) -- True = import public
340+ | IBCImport (Bool, FilePath) -- ^ True = import public
327 | IBCImportDir FilePath
341 | IBCImportDir FilePath
328 | IBCObj Codegen FilePath
342 | IBCObj Codegen FilePath
329 | IBCLib Codegen String
343 | IBCLib Codegen String
@@ -341,7 +355,7 @@ data IBCWrite = IBCFix FixDecl
341 | IBCCG Name
355 | IBCCG Name
342 | IBCDoc Name
356 | IBCDoc Name
343 | IBCCoercion Name
357 | IBCCoercion Name
344− | IBCDef Name -- i.e. main context
358+ | IBCDef Name -- ^ The main context.
345 | IBCNameHint (Name, Name)
359 | IBCNameHint (Name, Name)
346 | IBCLineApp FilePath Int PTerm
360 | IBCLineApp FilePath Int PTerm
347 | IBCErrorHandler Name
361 | IBCErrorHandler Name
@@ -373,9 +387,13 @@ idrisInit = IState initContext S.empty []
373 emptyContext S.empty M.empty emptyContext
387 emptyContext S.empty M.empty emptyContext
376−-- | The monad for the main REPL - reading and processing files and updating
390+-- | The monad for the main REPL - reading and processing files and
377−-- global state (hence the IO inner monad).
391+-- updating global state (hence the IO inner monad).
378−--type Idris = WriterT [Either String (IO ())] (State IState a))
394+-- type Idris = WriterT [Either String (IO ())] (State IState a))
379type Idris = StateT IState (ExceptT Err IO)
397type Idris = StateT IState (ExceptT Err IO)
381catchError :: Idris a -> (Err -> Idris a) -> Idris a
399catchError :: Idris a -> (Err -> Idris a) -> Idris a
@@ -441,10 +459,10 @@ data Command = Quit
441 | MakeWith Bool Int Name
459 | MakeWith Bool Int Name
442 | MakeCase Bool Int Name
460 | MakeCase Bool Int Name
443 | MakeLemma Bool Int Name
461 | MakeLemma Bool Int Name
444− | DoProofSearch Bool -- update file
462+ | DoProofSearch Bool -- update file
445− Bool -- recursive search
463+ Bool -- recursive search
446− Int -- depth
464+ Int -- depth
447− Name -- top level name
465+ Name -- top level name
448 [Name] -- hints
466 [Name] -- hints
449 | SetOpt Opt
467 | SetOpt Opt
450 | UnsetOpt Opt
468 | UnsetOpt Opt
@@ -459,7 +477,7 @@ data Command = Quit
459 | WhoCalls Name
477 | WhoCalls Name
460 | CallsWho Name
478 | CallsWho Name
461 | Browse [String]
479 | Browse [String]
462− | MakeDoc String -- IdrisDoc
480+ | MakeDoc String -- IdrisDoc
463 | Warranty
481 | Warranty
464 | PrintDef Name
482 | PrintDef Name
465 | PPrint OutputFmt Int PTerm
483 | PPrint OutputFmt Int PTerm
@@ -538,7 +556,7 @@ data Opt = Filename String
538 | ErrContext
556 | ErrContext
539 | ShowImpl
557 | ShowImpl
540 | Verbose
558 | Verbose
541− | Port String -- REPL TCP port
559+ | Port String -- ^ REPL TCP port
542 | IBCSubDir String
560 | IBCSubDir String
543 | ImportDir String
561 | ImportDir String
544 | PkgBuild String
562 | PkgBuild String
@@ -546,7 +564,7 @@ data Opt = Filename String
546 | PkgClean String
564 | PkgClean String
547 | PkgCheck String
565 | PkgCheck String
548 | PkgREPL String
566 | PkgREPL String
549− | PkgMkDoc String -- IdrisDoc
567+ | PkgMkDoc String -- IdrisDoc
550 | PkgTest String
568 | PkgTest String
551 | PkgIndex FilePath
569 | PkgIndex FilePath
552 | WarnOnly
570 | WarnOnly
@@ -572,20 +590,26 @@ data Opt = Filename String
572 | UseConsoleWidth ConsoleWidth
590 | UseConsoleWidth ConsoleWidth
573 | DumpHighlights
591 | DumpHighlights
574 | DesugarNats
592 | DesugarNats
575− | NoElimDeprecationWarnings -- ^ Don't show deprecation warnings for %elim
593+ | NoElimDeprecationWarnings -- ^ Don't show deprecation warnings for %elim
576 | NoOldTacticDeprecationWarnings -- ^ Don't show deprecation warnings for old-style tactics
594 | NoOldTacticDeprecationWarnings -- ^ Don't show deprecation warnings for old-style tactics
577 deriving (Show, Eq)
595 deriving (Show, Eq)
579−data ElabShellCmd = EQED | EAbandon | EUndo | EProofState | EProofTerm
597+data ElabShellCmd = EQED
580− | EEval PTerm | ECheck PTerm | ESearch PTerm
604+ | ESearch PTerm
581 | EDocStr (Either Name Const)
605 | EDocStr (Either Name Const)
582 deriving (Show, Eq)
606 deriving (Show, Eq)
584-- Parsed declarations
608-- Parsed declarations
586−data Fixity = Infixl { prec :: Int }
610+data Fixity = Infixl { prec :: Int }
587− | Infixr { prec :: Int }
611+ | Infixr { prec :: Int }
588− | InfixN { prec :: Int }
612+ | InfixN { prec :: Int }
589 | PrefixN { prec :: Int }
613 | PrefixN { prec :: Int }
590 deriving Eq
614 deriving Eq
@@ -594,9 +618,9 @@ deriving instance NFData Fixity
596instance Show Fixity where
620instance Show Fixity where
597− show (Infixl i) = "infixl " ++ show i
621+ show (Infixl i) = "infixl " ++ show i
598− show (Infixr i) = "infixr " ++ show i
622+ show (Infixr i) = "infixr " ++ show i
599− show (InfixN i) = "infix " ++ show i
623+ show (InfixN i) = "infix " ++ show i
600 show (PrefixN i) = "prefix " ++ show i
624 show (PrefixN i) = "prefix " ++ show i
602data FixDecl = Fix Fixity String
626data FixDecl = Fix Fixity String
@@ -621,22 +645,25 @@ deriving instance Binary Static
621deriving instance NFData Static
645deriving instance NFData Static
624−-- Mark bindings with their explicitness, and laziness
648+-- ^ Mark bindings with their explicitness, and laziness
625−data Plicity = Imp { pargopts :: [ArgOpt],
649+data Plicity = Imp { pargopts :: [ArgOpt]
626− pstatic :: Static,
650+ , pstatic :: Static
627− pparam :: Bool,
651+ , pparam :: Bool
628− pscoped :: Maybe ImplicitInfo, -- Nothing, if top level
652+ , pscoped :: Maybe ImplicitInfo -- ^ Nothing, if top level
629− pinsource :: Bool -- Explicitly written in source
653+ , pinsource :: Bool -- ^ Explicitly written in source
631− | Exp { pargopts :: [ArgOpt],
655+ | Exp { pargopts :: [ArgOpt]
632− pstatic :: Static,
656+ , pstatic :: Static
633− pparam :: Bool } -- this is a param (rather than index)
657+ , pparam :: Bool -- ^ this is a param (rather than index)
634− | Constraint { pargopts :: [ArgOpt],
659+ | Constraint { pargopts :: [ArgOpt]
635− pstatic :: Static }
660+ , pstatic :: Static
636− | TacImp { pargopts :: [ArgOpt],
662+ | TacImp { pargopts :: [ArgOpt]
637− pstatic :: Static,
663+ , pstatic :: Static
638− pscript :: PTerm }
664+ , pscript :: PTerm
639− deriving (Show, Eq, Data, Typeable)
666+ deriving (Show, Eq, Data, Typeable)
642deriving instance Binary Plicity
669deriving instance Binary Plicity
@@ -645,7 +672,7 @@ deriving instance NFData Plicity
646is_scoped :: Plicity -> Maybe ImplicitInfo
673is_scoped :: Plicity -> Maybe ImplicitInfo
647is_scoped (Imp _ _ _ s _) = s
674is_scoped (Imp _ _ _ s _) = s
648−is_scoped _ = Nothing
675+is_scoped _ = Nothing
650impl = Imp [] Dynamic False (Just (Impl False True)) False
677impl = Imp [] Dynamic False (Just (Impl False True)) False
@@ -659,21 +686,23 @@ constraint = Constraint [] Static
660tacimpl t = TacImp [] Dynamic t
687tacimpl t = TacImp [] Dynamic t
662−data FnOpt = Inlinable -- always evaluate when simplifying
689+data FnOpt = Inlinable -- ^ always evaluate when simplifying
663 | TotalFn | PartialFn | CoveringFn
690 | TotalFn | PartialFn | CoveringFn
664 | Coinductive | AssertTotal
691 | Coinductive | AssertTotal
665− | Dictionary -- type class dictionary, eval only when
693+ -- | type class dictionary, eval only when a function
666− -- a function argument, and further evaluation resutls
694+ -- argument, and further evaluation results.
667− | Implicit -- implicit coercion
696+ | Implicit -- ^ implicit coercion
668− | NoImplicit -- do not apply implicit coercions
697+ | NoImplicit -- ^ do not apply implicit coercions
669− | CExport String -- export, with a C name
698+ | CExport String -- ^ export, with a C name
670− | ErrorHandler -- ^^ an error handler for use with the ErrorReflection extension
699+ | ErrorHandler -- ^ an error handler for use with the ErrorReflection extension
671− | ErrorReverse -- ^^ attempt to reverse normalise before showing in error
700+ | ErrorReverse -- ^ attempt to reverse normalise before showing in error
672− | Reflection -- a reflecting function, compile-time only
701+ | Reflection -- ^ a reflecting function, compile-time only
673− | Specialise [(Name, Maybe Int)] -- specialise it, freeze these names
702+ | Specialise [(Name, Maybe Int)] -- ^ specialise it, freeze these names
674− | Constructor -- Data constructor type
703+ | Constructor -- ^ Data constructor type
675− | AutoHint -- use in auto implicit search
704+ | AutoHint -- ^ use in auto implicit search
676− | PEGenerated -- generated by partial evaluator
705+ | PEGenerated -- ^ generated by partial evaluator
677 deriving (Show, Eq)
706 deriving (Show, Eq)
679deriving instance Binary FnOpt
708deriving instance Binary FnOpt
@@ -699,67 +728,84 @@ type ProvideWhat = ProvideWhat' PTerm
699-- | Top-level declarations such as compiler directives, definitions,
728-- | Top-level declarations such as compiler directives, definitions,
700-- datatypes and typeclasses.
729-- datatypes and typeclasses.
701data PDecl' t
730data PDecl' t
731+ -- | Fixity declaration
702− = PFix FC Fixity [String] -- ^ Fixity declaration
732+ = PFix FC Fixity [String]
733+ -- | Type declaration (last FC is precise name location)
703− | PTy (Docstring (Either Err t)) [(Name, Docstring (Either Err t))] SyntaxInfo FC FnOpts Name FC t -- ^ Type declaration (last FC is precise name location)
734+ | PTy (Docstring (Either Err t)) [(Name, Docstring (Either Err t))] SyntaxInfo FC FnOpts Name FC t
735+ -- | Postulate, second FC is precise name location
704 | PPostulate Bool -- external def if true
736 | PPostulate Bool -- external def if true
705− (Docstring (Either Err t)) SyntaxInfo FC FC FnOpts Name t -- ^ Postulate, second FC is precise name location
737+ (Docstring (Either Err t)) SyntaxInfo FC FC FnOpts Name t
706− | PClauses FC FnOpts Name [PClause' t] -- ^ Pattern clause
739+ | PClauses FC FnOpts Name [PClause' t]
707− | PCAF FC Name t -- ^ Top level constant
740+ -- | Top level constant
708− | PData (Docstring (Either Err t)) [(Name, Docstring (Either Err t))] SyntaxInfo FC DataOpts (PData' t) -- ^ Data declaration.
741+ | PCAF FC Name t
742+ -- | Data declaration.
743+ | PData (Docstring (Either Err t)) [(Name, Docstring (Either Err t))] SyntaxInfo FC DataOpts (PData' t)
709− | PParams FC [(Name, t)] [PDecl' t] -- ^ Params block
744+ -- | Params block
745+ | PParams FC [(Name, t)] [PDecl' t]
710− | POpenInterfaces FC [Name] [PDecl' t] -- ^ Open block/declaration
746+ -- | Open block/declaration
747+ | POpenInterfaces FC [Name] [PDecl' t]
748+ -- | New namespace, where FC is accurate location of the namespace
711 | PNamespace String FC [PDecl' t]
750 | PNamespace String FC [PDecl' t]
712− -- ^ New namespace, where FC is accurate location of the
751+ -- | Record name.
713− -- namespace in the file
714− | PRecord (Docstring (Either Err t)) SyntaxInfo FC DataOpts
752+ | PRecord (Docstring (Either Err t)) SyntaxInfo FC DataOpts
715− Name -- Record name
753+ Name -- Record name
716− FC -- Record name precise location
754+ FC -- Record name precise location
717− [(Name, FC, Plicity, t)] -- Parameters, where FC is precise name span
755+ [(Name, FC, Plicity, t)] -- Parameters, where FC is precise name span
718− [(Name, Docstring (Either Err t))] -- Param Docs
756+ [(Name, Docstring (Either Err t))] -- Param Docs
719− [(Maybe (Name, FC), Plicity, t, Maybe (Docstring (Either Err t)))] -- Fields
757+ [(Maybe (Name, FC), Plicity, t, Maybe (Docstring (Either Err t)))] -- Fields
720− (Maybe (Name, FC)) -- Optional constructor name and location
758+ (Maybe (Name, FC)) -- Optional constructor name and location
721− (Docstring (Either Err t)) -- Constructor doc
759+ (Docstring (Either Err t)) -- Constructor doc
722− SyntaxInfo -- Constructor SyntaxInfo
760+ SyntaxInfo -- Constructor SyntaxInfo
723− -- ^ Record declaration
761+
762+ -- | Type class: arguments are documentation, syntax info, source
763+ -- location, constraints, class name, class name location,
764+ -- parameters, method declarations, optional constructor name
724− | PClass (Docstring (Either Err t)) SyntaxInfo FC
765+ | PClass (Docstring (Either Err t)) SyntaxInfo FC
725− [(Name, t)] -- constraints
766+ [(Name, t)] -- constraints
726− Name -- class name
767+ Name -- class name
727− FC -- accurate location of class name
768+ FC -- accurate location of class name
728− [(Name, FC, t)] -- parameters and precise locations
769+ [(Name, FC, t)] -- parameters and precise locations
729− [(Name, Docstring (Either Err t))] -- parameter docstrings
770+ [(Name, Docstring (Either Err t))] -- parameter docstrings
730− [(Name, FC)] -- determining parameters and precise locations
771+ [(Name, FC)] -- determining parameters and precise locations
731− [PDecl' t] -- declarations
772+ [PDecl' t] -- declarations
732− (Maybe (Name, FC)) -- instance constructor name and location
773+ (Maybe (Name, FC)) -- instance constructor name and location
733− (Docstring (Either Err t)) -- instance constructor docs
774+ (Docstring (Either Err t)) -- instance constructor docs
734− -- ^ Type class: arguments are documentation, syntax info, source location, constraints,
776+ -- | Instance declaration: arguments are documentation, syntax
735− -- class name, class name location, parameters, method declarations, optional constructor name
777+ -- info, source location, constraints, class name, parameters, full
736− | PInstance
778+ -- instance type, optional explicit name, and definitions
737− (Docstring (Either Err t)) -- Instance docs
779+ | PInstance (Docstring (Either Err t)) -- Instance docs
738− [(Name, Docstring (Either Err t))] -- Parameter docs
780+ [(Name, Docstring (Either Err t))] -- Parameter docs
739− SyntaxInfo
781+ SyntaxInfo
740− FC [(Name, t)] -- constraints
782+ FC [(Name, t)] -- constraints
741− [Name] -- parent dictionaries to search for constraints
783+ [Name] -- parent dictionaries to search for constraints
742− Accessibility
784+ Accessibility
744− Name -- class
786+ Name -- class
745− FC -- precise location of class
787+ FC -- precise location of class
746− [t] -- parameters
788+ [t] -- parameters
747− [(Name, t)] -- Extra names in scope in the body
789+ [(Name, t)] -- Extra names in scope in the body
748− t -- full instance type
790+ t -- full instance type
749− (Maybe Name) -- explicit name
791+ (Maybe Name) -- explicit name
750− [PDecl' t]
792+ [PDecl' t]
751− -- ^ Instance declaration: arguments are documentation, syntax info, source
752− -- location, constraints, class name, parameters, full instance
753− -- type, optional explicit name, and definitions
754 | PDSL Name (DSL' t) -- ^ DSL declaration
793 | PDSL Name (DSL' t) -- ^ DSL declaration
755− | PSyntax FC Syntax -- ^ Syntax definition
794+ | PSyntax FC Syntax -- ^ Syntax definition
756 | PMutual FC [PDecl' t] -- ^ Mutual block
795 | PMutual FC [PDecl' t] -- ^ Mutual block
757− | PDirective Directive -- ^ Compiler directive.
796+ | PDirective Directive -- ^ Compiler directive.
758− | PProvider (Docstring (Either Err t)) SyntaxInfo FC FC (ProvideWhat' t) Name -- ^ Type provider. The first t is the type, the second is the term. The second FC is precise highlighting location.
798+ -- | Type provider. The first t is the type, the second is the
799+ -- term. The second FC is precise highlighting location.
800+ | PProvider (Docstring (Either Err t)) SyntaxInfo FC FC (ProvideWhat' t) Name
759− | PTransform FC Bool t t -- ^ Source-to-source transformation rule. If
802+ -- | Source-to-source transformation rule. If bool is True, lhs and
760− -- bool is True, lhs and rhs must be convertible
803+ -- rhs must be convertible.
804+ | PTransform FC Bool t t
761− | PRunElabDecl FC t [String] -- ^ FC is decl-level, for errors, and
806+ -- | FC is decl-level, for errors, and Strings represent the
762− -- Strings represent the namespace
807+ -- namespace
808+ | PRunElabDecl FC t [String]
763 deriving Functor
809 deriving Functor
765deriving instance Binary PDecl'
811deriving instance Binary PDecl'
@@ -792,18 +838,19 @@ data RDeclInstructions = RTyDeclInstrs Name FC [PArg] Type
792 | RClausesInstrs Name [([(Name, Term)], Term, Term)]
838 | RClausesInstrs Name [([(Name, Term)], Term, Term)]
793 | RAddInstance Name Name
839 | RAddInstance Name Name
794 | RDatatypeDeclInstrs Name [PArg]
840 | RDatatypeDeclInstrs Name [PArg]
841+ -- | Datatype, constructors
795 | RDatatypeDefnInstrs Name Type [(Name, [PArg], Type)]
842 | RDatatypeDefnInstrs Name Type [(Name, [PArg], Type)]
796− -- ^ Datatype, constructors
843+
798-- | For elaborator state
845-- | For elaborator state
799data EState = EState {
846data EState = EState {
800− case_decls :: [(Name, PDecl)],
847+ case_decls :: [(Name, PDecl)]
801− delayed_elab :: [(Int, Elab' EState ())],
848+ , delayed_elab :: [(Int, Elab' EState ())]
802− new_tyDecls :: [RDeclInstructions],
849+ , new_tyDecls :: [RDeclInstructions]
803− highlighting :: [(FC, OutputAnnotation)],
850+ , highlighting :: [(FC, OutputAnnotation)]
804− auto_binds :: [Name], -- names bound as auto implicits
851+ , auto_binds :: [Name] -- ^ names bound as auto implicits
805− implicit_warnings :: [(FC, Name)] -- Implicit warnings to report (location and global name)
852+ , implicit_warnings :: [(FC, Name)] -- ^ Implicit warnings to report (location and global name)
808initEState :: EState
855initEState :: EState
809initEState = EState [] [] [] [] [] []
856initEState = EState [] [] [] [] [] []
@@ -835,20 +882,23 @@ deriving instance NFData PClause'
837-- | Data declaration
884-- | Data declaration
886+ -- | Data declaration
838−data PData' t = PDatadecl { d_name :: Name, -- ^ The name of the datatype
887+ PDatadecl { d_name :: Name -- ^ The name of the datatype
839− d_name_fc :: FC, -- ^ The precise location of the type constructor name
888+ , d_name_fc :: FC -- ^ The precise location of the type constructor name
840− d_tcon :: t, -- ^ Type constructor
889+ , d_tcon :: t -- ^ Type constructor
841− d_cons :: [(Docstring (Either Err PTerm), [(Name, Docstring (Either Err PTerm))], Name, FC, t, FC, [Name])] -- ^ Constructors
890+ , d_cons :: [(Docstring (Either Err PTerm), [(Name, Docstring (Either Err PTerm))], Name, FC, t, FC, [Name])] -- ^ Constructors
843− -- ^ Data declaration
844− | PLaterdecl { d_name :: Name, d_name_fc :: FC, d_tcon :: t }
845− -- ^ "Placeholder" for data whose constructors are defined later
892+ -- | "Placeholder" for data whose constructors are defined later
893+ | PLaterdecl { d_name :: Name
846− deriving Functor
896+ } deriving Functor
848-- | Transform the FCs in a PData and its associated terms. The first
898-- | Transform the FCs in a PData and its associated terms. The first
849−-- function transforms the general-purpose FCs, and the second transforms
899+-- function transforms the general-purpose FCs, and the second
850−-- those that are used for semantic source highlighting, so they can be
900+-- transforms those that are used for semantic source highlighting, so
851−-- treated specially.
901+-- they can be treated specially.
852mapPDataFC :: (FC -> FC) -> (FC -> FC) -> PData -> PData
902mapPDataFC :: (FC -> FC) -> (FC -> FC) -> PData -> PData
853mapPDataFC f g (PDatadecl n nfc tycon ctors) =
903mapPDataFC f g (PDatadecl n nfc tycon ctors) =
854 PDatadecl n (g nfc) (mapPTermFC f g tycon) (map ctorFC ctors)
904 PDatadecl n (g nfc) (mapPTermFC f g tycon) (map ctorFC ctors)
@@ -1030,56 +1080,76 @@ updateNs ns t = mapPT updateRef t
1030-- (map (updateDNs ns) ds)
1080-- (map (updateDNs ns) ds)
1031-- updateDNs ns c = c
1081-- updateDNs ns c = c
1083+data PunInfo = IsType
1033−data PunInfo = IsType | IsTerm | TypeOrTerm deriving (Eq, Show, Data, Typeable)
1086+ deriving (Eq, Show, Data, Typeable)
1035-- | High level language terms
1088-- | High level language terms
1036−data PTerm = PQuote Raw -- ^ Inclusion of a core term into the high-level language
1089+data PTerm = PQuote Raw -- ^ Inclusion of a core term into the
1090+ -- high-level language
1091+ | PRef FC [FC] Name
1092+ -- ^ A reference to a variable. The FC is its precise
1037− | PRef FC [FC] Name -- ^ A reference to a variable. The FC is its precise source location for highlighting. The list of FCs is a collection of additional highlighting locations.
1093+ -- source location for highlighting. The list of FCs is a
1094+ -- collection of additional highlighting locations.
1038− | PInferRef FC [FC] Name -- ^ A name to be defined later
1095+ | PInferRef FC [FC] Name -- ^ A name to be defined later
1039− | PPatvar FC Name -- ^ A pattern variable
1096+ | PPatvar FC Name -- ^ A pattern variable
1040− | PLam FC Name FC PTerm PTerm -- ^ A lambda abstraction. Second FC is name span.
1097+ | PLam FC Name FC PTerm PTerm -- ^ A lambda abstraction. Second FC is name span.
1041− | PPi Plicity Name FC PTerm PTerm -- ^ (n : t1) -> t2, where the FC is for the precise location of the variable
1098+ | PPi Plicity Name FC PTerm PTerm -- ^ (n : t1) -> t2, where the FC is for the precise location of the variable
1042− | PLet FC Name FC PTerm PTerm PTerm -- ^ A let binding (second FC is precise name location)
1099+ | PLet FC Name FC PTerm PTerm PTerm -- ^ A let binding (second FC is precise name location)
1043− | PTyped PTerm PTerm -- ^ Term with explicit type
1100+ | PTyped PTerm PTerm -- ^ Term with explicit type
1044− | PApp FC PTerm [PArg] -- ^ e.g. IO (), List Char, length x
1101+ | PApp FC PTerm [PArg] -- ^ e.g. IO (), List Char, length x
1045− | PWithApp FC PTerm PTerm -- ^ Application plus a 'with' argument
1102+ | PWithApp FC PTerm PTerm -- ^ Application plus a 'with' argument
1046− | PAppImpl PTerm [ImplicitInfo] -- ^ Implicit argument application (introduced during elaboration only)
1103+ | PAppImpl PTerm [ImplicitInfo] -- ^ Implicit argument application (introduced during elaboration only)
1047− | PAppBind FC PTerm [PArg] -- ^ implicitly bound application
1104+ | PAppBind FC PTerm [PArg] -- ^ implicitly bound application
1048− | PMatchApp FC Name -- ^ Make an application by type matching
1105+ | PMatchApp FC Name -- ^ Make an application by type matching
1049− | PIfThenElse FC PTerm PTerm PTerm -- ^ Conditional expressions - elaborated to an overloading of ifThenElse
1106+ | PIfThenElse FC PTerm PTerm PTerm -- ^ Conditional expressions - elaborated to an overloading of ifThenElse
1050− | PCase FC PTerm [(PTerm, PTerm)] -- ^ A case expression. Args are source location, scrutinee, and a list of pattern/RHS pairs
1107+ | PCase FC PTerm [(PTerm, PTerm)] -- ^ A case expression. Args are source location, scrutinee, and a list of pattern/RHS pairs
1051− | PTrue FC PunInfo -- ^ Unit type..?
1108+ | PTrue FC PunInfo -- ^ Unit type..?
1052− | PResolveTC FC -- ^ Solve this dictionary by type class resolution
1109+ | PResolveTC FC -- ^ Solve this dictionary by type class resolution
1053 | PRewrite FC (Maybe Name) PTerm PTerm (Maybe PTerm)
1110 | PRewrite FC (Maybe Name) PTerm PTerm (Maybe PTerm)
1054− -- ^ "rewrite" syntax, with optional rewriting function
1111+ -- ^ "rewrite" syntax, with optional rewriting function and
1055− -- and optional result type
1112+ -- optional result type
1113+ | PPair FC [FC] PunInfo PTerm PTerm
1114+ -- ^ A pair (a, b) and whether it's a product type or a
1056− | PPair FC [FC] PunInfo PTerm PTerm -- ^ A pair (a, b) and whether it's a product type or a pair (solved by elaboration). The list of FCs is its punctuation.
1115+ -- pair (solved by elaboration). The list of FCs is its
1117+ | PDPair FC [FC] PunInfo PTerm PTerm PTerm
1118+ -- ^ A dependent pair (tm : a ** b) and whether it's a
1057− | PDPair FC [FC] PunInfo PTerm PTerm PTerm -- ^ A dependent pair (tm : a ** b) and whether it's a sigma type or a pair that inhabits one (solved by elaboration). The [FC] is its punctuation.
1119+ -- sigma type or a pair that inhabits one (solved by
1120+ -- elaboration). The [FC] is its punctuation.
1058− | PAs FC Name PTerm -- ^ @-pattern, valid LHS only
1121+ | PAs FC Name PTerm -- ^ @-pattern, valid LHS only
1059 | PAlternative [(Name, Name)] PAltType [PTerm] -- ^ (| A, B, C|). Includes unapplied unique name mappings for mkUniqueNames.
1122 | PAlternative [(Name, Name)] PAltType [PTerm] -- ^ (| A, B, C|). Includes unapplied unique name mappings for mkUniqueNames.
1060− | PHidden PTerm -- ^ Irrelevant or hidden pattern
1123+ | PHidden PTerm -- ^ Irrelevant or hidden pattern
1061− | PType FC -- ^ 'Type' type
1124+ | PType FC -- ^ 'Type' type
1062− | PUniverse Universe -- ^ Some universe
1125+ | PUniverse Universe -- ^ Some universe
1063− | PGoal FC PTerm Name PTerm -- ^ quoteGoal, used for %reflection functions
1126+ | PGoal FC PTerm Name PTerm -- ^ quoteGoal, used for %reflection functions
1064− | PConstant FC Const -- ^ Builtin types
1127+ | PConstant FC Const -- ^ Builtin types
1065− | Placeholder -- ^ Underscore
1128+ | Placeholder -- ^ Underscore
1066− | PDoBlock [PDo] -- ^ Do notation
1129+ | PDoBlock [PDo] -- ^ Do notation
1067− | PIdiom FC PTerm -- ^ Idiom brackets
1130+ | PIdiom FC PTerm -- ^ Idiom brackets
1068 | PReturn FC
1131 | PReturn FC
1069− | PMetavar FC Name -- ^ A metavariable, ?name, and its precise location
1132+ | PMetavar FC Name -- ^ A metavariable, ?name, and its precise location
1070− | PProof [PTactic] -- ^ Proof script
1133+ | PProof [PTactic] -- ^ Proof script
1071− | PTactics [PTactic] -- ^ As PProof, but no auto solving
1134+ | PTactics [PTactic] -- ^ As PProof, but no auto solving
1072− | PElabError Err -- ^ Error to report on elaboration
1135+ | PElabError Err -- ^ Error to report on elaboration
1073− | PImpossible -- ^ Special case for declaring when an LHS can't typecheck
1136+ | PImpossible -- ^ Special case for declaring when an LHS can't typecheck
1074− | PCoerced PTerm -- ^ To mark a coerced argument, so as not to coerce twice
1137+ | PCoerced PTerm -- ^ To mark a coerced argument, so as not to coerce twice
1075− | PDisamb [[T.Text]] PTerm -- ^ Preferences for explicit namespaces
1138+ | PDisamb [[T.Text]] PTerm -- ^ Preferences for explicit namespaces
1076− | PUnifyLog PTerm -- ^ dump a trace of unifications when building term
1139+ | PUnifyLog PTerm -- ^ dump a trace of unifications when building term
1077− | PNoImplicits PTerm -- ^ never run implicit converions on the term
1140+ | PNoImplicits PTerm -- ^ never run implicit converions on the term
1078− | PQuasiquote PTerm (Maybe PTerm) -- ^ `(Term [: Term])
1141+ | PQuasiquote PTerm (Maybe PTerm) -- ^ `(Term [: Term])
1079− | PUnquote PTerm -- ^ ~Term
1142+ | PUnquote PTerm -- ^ ~Term
1143+ | PQuoteName Name Bool FC
1144+ -- ^ `{n} where the FC is the precise highlighting for
1080− | PQuoteName Name Bool FC -- ^ `{n} where the FC is the precise highlighting for the name in particular. If the Bool is False, then it's `{{n}} and the name won't be resolved.
1145+ -- the name in particular. If the Bool is False, then
1146+ -- it's `{{n}} and the name won't be resolved.
1147+ | PRunElab FC PTerm [String]
1081− | PRunElab FC PTerm [String] -- ^ %runElab tm - New-style proof script. Args are location, script, enclosing namespace.
1148+ -- ^ %runElab tm - New-style proof script. Args are
1149+ -- location, script, enclosing namespace.
1150+ | PConstSugar FC PTerm
1151+ -- ^ A desugared constant. The FC is a precise source
1082− | PConstSugar FC PTerm -- ^ A desugared constant. The FC is a precise source location that will be used to highlight it later.
1152+ -- location that will be used to highlight it later.
1083 deriving (Eq, Data, Typeable)
1153 deriving (Eq, Data, Typeable)
1085data PAltType = ExactlyOne Bool -- ^ flag sets whether delay is allowed
1155data PAltType = ExactlyOne Bool -- ^ flag sets whether delay is allowed
@@ -1249,9 +1319,9 @@ instance Sized a => Sized (PTactic' a) where
1249type PTactic = PTactic' PTerm
1319type PTactic = PTactic' PTerm
1251data PDo' t = DoExp FC t
1321data PDo' t = DoExp FC t
1252− | DoBind FC Name FC t -- ^ second FC is precise name location
1322+ | DoBind FC Name FC t -- ^ second FC is precise name location
1253 | DoBindP FC t t [(t,t)]
1323 | DoBindP FC t t [(t,t)]
1254− | DoLet FC Name FC t t -- ^ second FC is precise name location
1324+ | DoLet FC Name FC t t -- ^ second FC is precise name location
1255 | DoLetP FC t t
1325 | DoLetP FC t t
1256 deriving (Eq, Functor, Data, Typeable)
1326 deriving (Eq, Functor, Data, Typeable)
@@ -1262,9 +1332,9 @@ deriving instance NFData PDo'
1262instance Sized a => Sized (PDo' a) where
1332instance Sized a => Sized (PDo' a) where
1263 size (DoExp fc t) = 1 + size fc + size t
1333 size (DoExp fc t) = 1 + size fc + size t
1264 size (DoBind fc nm nfc t) = 1 + size fc + size nm + size nfc + size t
1334 size (DoBind fc nm nfc t) = 1 + size fc + size nm + size nfc + size t
1265− size (DoBindP fc l r alts) = 1 + size fc + size l + size r + size alts
1335+ size (DoBindP fc l r alts) = 1 + size fc + size l + size r + size alts
1266− size (DoLet fc nm nfc l r) = 1 + size fc + size nm + size l + size r
1336+ size (DoLet fc nm nfc l r) = 1 + size fc + size nm + size l + size r
1267− size (DoLetP fc l r) = 1 + size fc + size l + size r
1337+ size (DoLetP fc l r) = 1 + size fc + size l + size r
1269type PDo = PDo' PTerm
1339type PDo = PDo' PTerm
@@ -1272,33 +1342,40 @@ type PDo = PDo' PTerm
1272-- things early which will help give a more concrete type to other
1342-- things early which will help give a more concrete type to other
1273-- variables, e.g. a before (interpTy a).
1343-- variables, e.g. a before (interpTy a).
1275−data PArg' t = PImp { priority :: Int,
1345+data PArg' t = PImp { priority :: Int
1276− machine_inf :: Bool, -- true if the machine inferred it
1346+ , machine_inf :: Bool -- ^ true if the machine inferred it
1277− argopts :: [ArgOpt],
1347+ , argopts :: [ArgOpt]
1278− pname :: Name,
1348+ , pname :: Name
1279− getTm :: t }
1349+ , getTm :: t
1280− | PExp { priority :: Int,
1351+ | PExp { priority :: Int
1281− argopts :: [ArgOpt],
1352+ , argopts :: [ArgOpt]
1282− pname :: Name,
1353+ , pname :: Name
1283− getTm :: t }
1354+ , getTm :: t
1284− | PConstraint { priority :: Int,
1356+ | PConstraint { priority :: Int
1285− argopts :: [ArgOpt],
1357+ , argopts :: [ArgOpt]
1286− pname :: Name,
1358+ , pname :: Name
1287− getTm :: t }
1359+ , getTm :: t
1288− | PTacImplicit { priority :: Int,
1361+ | PTacImplicit { priority :: Int
1289− argopts :: [ArgOpt],
1362+ , argopts :: [ArgOpt]
1290− pname :: Name,
1363+ , pname :: Name
1291− getScript :: t,
1364+ , getScript :: t
1292− getTm :: t }
1365+ , getTm :: t
1293− deriving (Show, Eq, Functor, Data, Typeable)
1367+ deriving (Show, Eq, Functor, Data, Typeable)
1295−data ArgOpt = AlwaysShow | HideDisplay | InaccessibleArg | UnknownImp
1369+data ArgOpt = AlwaysShow
1296− deriving (Show, Eq, Data, Typeable)
1373+ deriving (Show, Eq, Data, Typeable)
1298instance Sized a => Sized (PArg' a) where
1375instance Sized a => Sized (PArg' a) where
1299 size (PImp p _ l nm trm) = 1 + size nm + size trm
1376 size (PImp p _ l nm trm) = 1 + size nm + size trm
1300 size (PExp p l nm trm) = 1 + size nm + size trm
1377 size (PExp p l nm trm) = 1 + size nm + size trm
1301− size (PConstraint p l nm trm) = 1 + size nm +size nm + size trm
1378+ size (PConstraint p l nm trm) = 1 + size nm + size nm + size trm
1302 size (PTacImplicit p l nm scr trm) = 1 + size nm + size scr + size trm
1379 size (PTacImplicit p l nm scr trm) = 1 + size nm + size scr + size trm
@@ -1375,28 +1452,30 @@ highestFC (PAppImpl t _) = highestFC t
1376-- Type class data
1453-- Type class data
1455+data ClassInfo = CI {
1378−data ClassInfo = CI { instanceCtorName :: Name,
1456+ instanceCtorName :: Name
1379− class_methods :: [(Name, (Bool, FnOpts, PTerm))], -- flag whether it's a "data" method
1457+ , class_methods :: [(Name, (Bool, FnOpts, PTerm))] -- ^ flag whether it's a "data" method
1380− class_defaults :: [(Name, (Name, PDecl))], -- method name -> default impl
1458+ , class_defaults :: [(Name, (Name, PDecl))] -- ^ method name -> default impl
1381− class_default_superclasses :: [PDecl],
1459+ , class_default_superclasses :: [PDecl]
1382− class_params :: [Name],
1460+ , class_params :: [Name]
1383− class_instances :: [(Name, Bool)], -- the Bool is whether to include in instance search, so named instances are excluded
1461+ , class_instances :: [(Name, Bool)] -- ^ the Bool is whether to include in instance search, so named instances are excluded
1384− class_determiners :: [Int] }
1462+ , class_determiners :: [Int]
1385− deriving Show
1463+ } deriving Show
1387deriving instance Binary ClassInfo
1465deriving instance Binary ClassInfo
1388deriving instance NFData ClassInfo
1466deriving instance NFData ClassInfo
1391-- Record data
1469-- Record data
1470+data RecordInfo = RI {
1392−data RecordInfo = RI { record_parameters :: [(Name,PTerm)],
1471+ record_parameters :: [(Name,PTerm)]
1393− record_constructor :: Name,
1472+ , record_constructor :: Name
1394− record_projections :: [Name] }
1473+ , record_projections :: [Name]
1395− deriving Show
1474+ } deriving Show
1397-- Type inference data
1476-- Type inference data
1399−data TIData = TIPartial -- ^ a function with a partially defined type
1478+data TIData = TIPartial -- ^ a function with a partially defined type
1400 | TISolution [Term] -- ^ possible solutions to a metavariable in a type
1479 | TISolution [Term] -- ^ possible solutions to a metavariable in a type
1401 deriving Show
1480 deriving Show
@@ -1408,27 +1487,28 @@ deriving instance Binary FnInfo
1408deriving instance NFData FnInfo
1487deriving instance NFData FnInfo
1490+data OptInfo = Optimise {
1411−data OptInfo = Optimise { inaccessible :: [(Int,Name)], -- includes names for error reporting
1491+ inaccessible :: [(Int,Name)] -- includes names for error reporting
1412− detaggable :: Bool }
1492+ , detaggable :: Bool
1413− deriving Show
1493+ } deriving Show
1415deriving instance Binary OptInfo
1495deriving instance Binary OptInfo
1416deriving instance NFData OptInfo
1496deriving instance NFData OptInfo
1419-- | Syntactic sugar info
1499-- | Syntactic sugar info
1420−data DSL' t = DSL { dsl_bind :: t,
1500+data DSL' t = DSL {
1421− dsl_return :: t,
1502+ , dsl_return :: t
1422− dsl_apply :: t,
1503+ , dsl_apply :: t
1423− dsl_pure :: t,
1504+ , dsl_pure :: t
1424− dsl_var :: Maybe t,
1505+ , dsl_var :: Maybe t
1425− index_first :: Maybe t,
1506+ , index_first :: Maybe t
1426− index_next :: Maybe t,
1507+ , index_next :: Maybe t
1427− dsl_lambda :: Maybe t,
1508+ , dsl_lambda :: Maybe t
1428− dsl_let :: Maybe t,
1509+ , dsl_let :: Maybe t
1429− dsl_pi :: Maybe t
1510+ , dsl_pi :: Maybe t
1431− deriving (Show, Functor)
1511+ } deriving (Show, Functor)
1433deriving instance Binary DSL'
1513deriving instance Binary DSL'
1434deriving instance NFData DSL'
1514deriving instance NFData DSL'
@@ -1436,7 +1516,9 @@ deriving instance NFData DSL'
1437type DSL = DSL' PTerm
1517type DSL = DSL' PTerm
1439−data SynContext = PatternSyntax | TermSyntax | AnySyntax
1519+data SynContext = PatternSyntax
1440 deriving Show
1522 deriving Show
1442deriving instance Binary SynContext
1524deriving instance Binary SynContext
@@ -1536,24 +1618,25 @@ deriving instance Binary Using
1536deriving instance NFData Using
1618deriving instance NFData Using
1539−data SyntaxInfo = Syn { using :: [Using],
1621+data SyntaxInfo = Syn {
1540− syn_params :: [(Name, PTerm)],
1623+ , syn_params :: [(Name, PTerm)]
1541− syn_namespace :: [String],
1624+ , syn_namespace :: [String]
1542− no_imp :: [Name],
1625+ , no_imp :: [Name]
1626+ , imp_methods :: [Name]
1543− imp_methods :: [Name], -- class methods. When expanding
1627+ -- ^ class methods. When expanding implicits, these should be
1544− -- implicits, these should be expanded even under
1628+ -- expanded even under binders
1546− decoration :: Name -> Name,
1629+ , decoration :: Name -> Name
1547− inPattern :: Bool,
1630+ , inPattern :: Bool
1548− implicitAllowed :: Bool,
1631+ , implicitAllowed :: Bool
1549− constraintAllowed :: Bool,
1632+ , constraintAllowed :: Bool
1550− maxline :: Maybe Int,
1633+ , maxline :: Maybe Int
1551− mut_nesting :: Int,
1634+ , mut_nesting :: Int
1552− dsl_info :: DSL,
1635+ , dsl_info :: DSL
1553− syn_in_quasiquote :: Int,
1636+ , syn_in_quasiquote :: Int
1554− syn_toplevel :: Bool,
1637+ , syn_toplevel :: Bool
1555− withAppAllowed :: Bool }
1638+ , withAppAllowed :: Bool
1556− deriving Show
1639+ } deriving Show
1558deriving instance NFData SyntaxInfo
1641deriving instance NFData SyntaxInfo
1559deriving instance Binary SyntaxInfo
1642deriving instance Binary SyntaxInfo
@@ -1693,9 +1776,9 @@ instance Show PData where
1693instance Pretty PTerm OutputAnnotation where
1776instance Pretty PTerm OutputAnnotation where
1694 pretty = prettyImp defaultPPOption
1777 pretty = prettyImp defaultPPOption
1696−-- | Colourise annotations according to an Idris state. It ignores the names
1779+-- | Colourise annotations according to an Idris state. It ignores the
1697−-- in the annotation, as there's no good way to show extended information on a
1780+-- names in the annotation, as there's no good way to show extended
1698−-- terminal.
1781+-- information on a terminal.
1699annotationColour :: IState -> OutputAnnotation -> Maybe IdrisColour
1782annotationColour :: IState -> OutputAnnotation -> Maybe IdrisColour
1700annotationColour ist _ | not (idris_colourRepl ist) = Nothing
1783annotationColour ist _ | not (idris_colourRepl ist) = Nothing
1701annotationColour ist (AnnConst c) =
1784annotationColour ist (AnnConst c) =
@@ -1724,8 +1807,8 @@ annotationColour ist (AnnTextFmt fmt) = Just (colour fmt)
1724annotationColour ist _ = Nothing
1807annotationColour ist _ = Nothing
1727−-- | Colourise annotations according to an Idris state. It ignores the names
1810+-- | Colourise annotations according to an Idris state. It ignores the
1728−-- in the annotation, as there's no good way to show extended
1811+-- names in the annotation, as there's no good way to show extended
1729-- information on a terminal. Note that strings produced this way will
1812-- information on a terminal. Note that strings produced this way will
1730-- not be coloured on Windows, so the use of the colour rendering
1813-- not be coloured on Windows, so the use of the colour rendering
1731-- functions in Idris.Output is to be preferred.
1814-- functions in Idris.Output is to be preferred.
@@ -1735,9 +1818,10 @@ consoleDecorate ist ann = maybe id colourise (annotationColour ist ann)
1735isPostulateName :: Name -> IState -> Bool
1818isPostulateName :: Name -> IState -> Bool
1736isPostulateName n ist = S.member n (idris_postulates ist)
1819isPostulateName n ist = S.member n (idris_postulates ist)
1738−-- | Pretty-print a high-level closed Idris term with no information about precedence/associativity
1821+-- | Pretty-print a high-level closed Idris term with no information
1822+-- about precedence/associativity
1739−prettyImp :: PPOption -- ^^ pretty printing options
1823+prettyImp :: PPOption -- ^ pretty printing options
1740− -> PTerm -- ^^ the term to pretty-print
1824+ -> PTerm -- ^ the term to pretty-print
1741 -> Doc OutputAnnotation
1825 -> Doc OutputAnnotation
1742prettyImp impl = pprintPTerm impl [] [] []
1826prettyImp impl = pprintPTerm impl [] [] []
@@ -1747,12 +1831,13 @@ prettyImp impl = pprintPTerm impl [] [] []
1747prettyIst :: IState -> PTerm -> Doc OutputAnnotation
1831prettyIst :: IState -> PTerm -> Doc OutputAnnotation
1748prettyIst ist = pprintPTerm (ppOptionIst ist) [] [] (idris_infixes ist)
1832prettyIst ist = pprintPTerm (ppOptionIst ist) [] [] (idris_infixes ist)
1750−-- | Pretty-print a high-level Idris term in some bindings context with infix info
1834+-- | Pretty-print a high-level Idris term in some bindings context
1751−pprintPTerm :: PPOption -- ^^ pretty printing options
1836+pprintPTerm :: PPOption -- ^ pretty printing options
1752− -> [(Name, Bool)] -- ^^ the currently-bound names and whether they are implicit
1837+ -> [(Name, Bool)] -- ^ the currently-bound names and whether they are implicit
1753− -> [Name] -- ^^ names to always show in pi, even if not used
1838+ -> [Name] -- ^ names to always show in pi, even if not used
1754− -> [FixDecl] -- ^^ Fixity declarations
1839+ -> [FixDecl] -- ^ Fixity declarations
1755− -> PTerm -- ^^ the term to pretty-print
1840+ -> PTerm -- ^ the term to pretty-print
1756 -> Doc OutputAnnotation
1841 -> Doc OutputAnnotation
1757pprintPTerm ppo bnd docArgs infixes = prettySe (ppopt_depth ppo) startPrec bnd
1842pprintPTerm ppo bnd docArgs infixes = prettySe (ppopt_depth ppo) startPrec bnd
@@ -2125,8 +2210,8 @@ basename :: Name -> Name
2125basename (NS n _) = basename n
2210basename (NS n _) = basename n
2126basename n = n
2211basename n = n
2128−-- | Determine whether a name was the one inserted for a hole or
2213+-- | Determine whether a name was the one inserted for a hole or guess
2129−-- guess by the delaborator
2214+-- by the delaborator
2130isHoleName :: Name -> Bool
2215isHoleName :: Name -> Bool
2131isHoleName (UN n) = n == T.pack "[__]"
2216isHoleName (UN n) = n == T.pack "[__]"
2132isHoleName _ = False
2217isHoleName _ = False
@@ -2136,12 +2221,11 @@ containsHole :: PTerm -> Bool
2136containsHole pterm = or [isHoleName n | PRef _ _ n <- take 1000 $ universe pterm]
2221containsHole pterm = or [isHoleName n | PRef _ _ n <- take 1000 $ universe pterm]
2138-- | Pretty-printer helper for names that attaches the correct annotations
2223-- | Pretty-printer helper for names that attaches the correct annotations
2140− :: Bool -- ^^ whether the name should be parenthesised if it is an infix operator
2224+prettyName :: Bool -- ^ whether the name should be parenthesised if it is an infix operator
2141− -> Bool -- ^^ whether to show namespaces
2225+ -> Bool -- ^ whether to show namespaces
2142− -> [(Name, Bool)] -- ^^ the current bound variables and whether they are implicit
2226+ -> [(Name, Bool)] -- ^ the current bound variables and whether they are implicit
2143− -> Name -- ^^ the name to pprint
2227+ -> Name -- ^ the name to pprint
2144− -> Doc OutputAnnotation
2228+ -> Doc OutputAnnotation
2145prettyName infixParen showNS bnd n
2229prettyName infixParen showNS bnd n
2146 | (MN _ s) <- n, isPrefixOf "_" $ T.unpack s = text "_"
2230 | (MN _ s) <- n, isPrefixOf "_" $ T.unpack s = text "_"
2147 | (UN n') <- n, T.unpack n' == "_" = text "_"
2231 | (UN n') <- n, T.unpack n' == "_" = text "_"
@@ -2228,11 +2312,11 @@ getAll = map getTm
2230-- | Show Idris name
2314-- | Show Idris name
2231−showName :: Maybe IState -- ^^ the Idris state, for information about names and colours
2315+showName :: Maybe IState -- ^ the Idris state, for information about names and colours
2232− -> [(Name, Bool)] -- ^^ the bound variables and whether they're implicit
2316+ -> [(Name, Bool)] -- ^ the bound variables and whether they're implicit
2233− -> PPOption -- ^^ pretty printing options
2317+ -> PPOption -- ^ pretty printing options
2234− -> Bool -- ^^ whether to colourise
2318+ -> Bool -- ^ whether to colourise
2235− -> Name -- ^^ the term to show
2319+ -> Name -- ^ the term to show
2236 -> String
2320 -> String
2237showName ist bnd ppo colour n = case ist of
2321showName ist bnd ppo colour n = case ist of
2238 Just i -> if colour then colourise n (idris_colourTheme i) else showbasic n
2322 Just i -> if colour then colourise n (idris_colourTheme i) else showbasic n
@@ -2256,8 +2340,8 @@ showName ist bnd ppo colour n = case ist of
2256 -- (like error messages). Thus, unknown vars are colourised as implicits.
2340 -- (like error messages). Thus, unknown vars are colourised as implicits.
2257 | otherwise -> colouriseImplicit t name
2341 | otherwise -> colouriseImplicit t name
2259−showTm :: IState -- ^^ the Idris state, for information about identifiers and colours
2343+showTm :: IState -- ^ the Idris state, for information about identifiers and colours
2260− -> PTerm -- ^^ the term to show
2344+ -> PTerm -- ^ the term to show
2261 -> String
2345 -> String
2262showTm ist = displayDecorated (consoleDecorate ist) .
2346showTm ist = displayDecorated (consoleDecorate ist) .
2263 renderPretty 0.8 100000 .
2347 renderPretty 0.8 100000 .