@@ -46,10 +46,12 @@ defaultOpts = IOption 0 False False True False False True True ViaC Executable "
46-- This will include all the functions and data declarations, plus fixity declarations
46-- This will include all the functions and data declarations, plus fixity declarations
47-- and syntax macros.
47-- and syntax macros.
49+-- | The global state used in the Idris monad
49data IState = IState {
50data IState = IState {
50− tt_ctxt :: Context,
51+ tt_ctxt :: Context, -- ^ All the currently defined names and their terms
51 idris_constraints :: [(UConstraint, FC)],
52 idris_constraints :: [(UConstraint, FC)],
53+ -- ^ A list of universe constraints and their corresponding source locations
52− idris_infixes :: [FixDecl],
54+ idris_infixes :: [FixDecl], -- ^ Currently defined infix operators
53 idris_implicits :: Ctxt [PArg],
55 idris_implicits :: Ctxt [PArg],
54 idris_statics :: Ctxt [Bool],
56 idris_statics :: Ctxt [Bool],
55 idris_classes :: Ctxt ClassInfo,
57 idris_classes :: Ctxt ClassInfo,
@@ -65,11 +67,11 @@ data IState = IState {
65 idris_log :: String,
67 idris_log :: String,
66 idris_options :: IOption,
68 idris_options :: IOption,
67 idris_name :: Int,
69 idris_name :: Int,
68− idris_metavars :: [Name],
70+ idris_metavars :: [Name], -- ^ The currently defined but not proven metavariables
69 idris_coercions :: [Name],
71 idris_coercions :: [Name],
70 syntax_rules :: [Syntax],
72 syntax_rules :: [Syntax],
71 syntax_keywords :: [String],
73 syntax_keywords :: [String],
72− imported :: [FilePath],
74+ imported :: [FilePath], -- ^ The imported modules
73 idris_scprims :: [(Name, (Int, PrimFn))],
75 idris_scprims :: [(Name, (Int, PrimFn))],
74 idris_objs :: [FilePath],
76 idris_objs :: [FilePath],
75 idris_libs :: [String],
77 idris_libs :: [String],
@@ -136,7 +138,7 @@ idrisInit = IState initContext [] [] emptyContext emptyContext emptyContext
136 [] "" defaultOpts 6 [] [] [] [] [] [] [] [] []
138 [] "" defaultOpts 6 [] [] [] [] [] [] [] [] []
137 [] Nothing Nothing [] [] [] Hidden False [] Nothing
139 [] Nothing Nothing [] [] [] Hidden False [] Nothing
139−-- The monad for the main REPL - reading and processing files and updating
141+-- | The monad for the main REPL - reading and processing files and updating
140-- global state (hence the IO inner monad).
142-- global state (hence the IO inner monad).
141type Idris = StateT IState IO
143type Idris = StateT IState IO
@@ -149,6 +151,7 @@ data Target = ViaC
149 | Bytecode
151 | Bytecode
150 deriving (Show, Eq)
152 deriving (Show, Eq)
152data Command = Quit
155data Command = Quit
154 | Eval PTerm
157 | Eval PTerm
@@ -296,32 +299,37 @@ type FnOpts = [FnOpt]
296inlinable :: FnOpts -> Bool
299inlinable :: FnOpts -> Bool
297inlinable = elem Inlinable
300inlinable = elem Inlinable
302+-- | Top-level declarations such as compiler directives, definitions,
303+-- datatypes and typeclasses.
299−data PDecl' t
304+data PDecl' t
300− = PFix FC Fixity [String] -- fixity declaration
305+ = PFix FC Fixity [String] -- ^ Fixity declaration
301− | PTy String SyntaxInfo FC FnOpts Name t -- type declaration
306+ | PTy String SyntaxInfo FC FnOpts Name t -- ^ Type declaration
302− | PPostulate String SyntaxInfo FC FnOpts Name t
307+ | PPostulate String SyntaxInfo FC FnOpts Name t -- ^ Postulate
303− | PClauses FC FnOpts Name [PClause' t] -- pattern clause
308+ | PClauses FC FnOpts Name [PClause' t] -- ^ Pattern clause
304− | PCAF FC Name t -- top level constant
309+ | PCAF FC Name t -- ^ Top level constant
305− | PData String SyntaxInfo FC Bool -- codata
310+ | PData String SyntaxInfo FC Bool (PData' t) -- ^ Data declaration. The Bool argument is True for codata.
306− (PData' t) -- data declaration
307− | PParams FC [(Name, t)] [PDecl' t] -- params block
311+ | PParams FC [(Name, t)] [PDecl' t] -- ^ Params block
308− | PNamespace String [PDecl' t] -- new namespace
312+ | PNamespace String [PDecl' t] -- ^ New namespace
309− | PRecord String SyntaxInfo FC Name t String Name t -- record declaration
313+ | PRecord String SyntaxInfo FC Name t String Name t -- ^ Record declaration
310 | PClass String SyntaxInfo FC
314 | PClass String SyntaxInfo FC
311 [t] -- constraints
315 [t] -- constraints
313 [(Name, t)] -- parameters
317 [(Name, t)] -- parameters
314 [PDecl' t] -- declarations
318 [PDecl' t] -- declarations
319+ -- ^ Type class: arguments are documentation, syntax info, source location, constraints,
320+ -- class name, parameters, method declarations
315 | PInstance SyntaxInfo FC [t] -- constraints
321 | PInstance SyntaxInfo FC [t] -- constraints
316 Name -- class
322 Name -- class
317 [t] -- parameters
323 [t] -- parameters
318 t -- full instance type
324 t -- full instance type
319 (Maybe Name) -- explicit name
325 (Maybe Name) -- explicit name
320 [PDecl' t]
326 [PDecl' t]
327+ -- ^ Instance declaration: arguments are syntax info, source location, constraints,
328+ -- class name, parameters, full instance type, optional explicit name, and definitions
321− | PDSL Name (DSL' t)
329+ | PDSL Name (DSL' t) -- ^ DSL declaration
322− | PSyntax FC Syntax
330+ | PSyntax FC Syntax -- ^ Syntax definition
323− | PMutual FC [PDecl' t]
331+ | PMutual FC [PDecl' t] -- ^ Mutual block
324− | PDirective (Idris ())
332+ | PDirective (Idris ()) -- ^ Compiler directive. The parser inserts the corresponding action in the Idris monad.
325 deriving Functor
333 deriving Functor
327deriving instance Binary PDecl'
335deriving instance Binary PDecl'
@@ -336,10 +344,14 @@ data PClause' t = PClause FC Name t [t] t [PDecl' t]
336deriving instance Binary PClause'
344deriving instance Binary PClause'
347+-- | Data declaration
339−data PData' t = PDatadecl { d_name :: Name,
348+data PData' t = PDatadecl { d_name :: Name, -- ^ The name of the datatype
340− d_tcon :: t,
349+ d_tcon :: t, -- ^ Type constructor
341− d_cons :: [(String, Name, t, FC)] }
350+ d_cons :: [(String, Name, t, FC)] -- ^ Constructors
352+ -- ^ Data declaration
342 | PLaterdecl { d_name :: Name, d_tcon :: t }
353 | PLaterdecl { d_name :: Name, d_tcon :: t }
354+ -- ^ "Placeholder" for data whose constructors are defined later
343 deriving Functor
355 deriving Functor
345deriving instance Binary PData'
357deriving instance Binary PData'
@@ -414,16 +426,15 @@ updateNs ns t = mapPT updateRef t
414-- (map (updateDNs ns) ds)
426-- (map (updateDNs ns) ds)
415-- updateDNs ns c = c
427-- updateDNs ns c = c
417−-- High level language terms
429+-- | High level language terms
419data PTerm = PQuote Raw
430data PTerm = PQuote Raw
420 | PRef FC Name
431 | PRef FC Name
421− | PInferRef FC Name -- a name to be defined later
432+ | PInferRef FC Name -- ^ A name to be defined later
422 | PPatvar FC Name
433 | PPatvar FC Name
423 | PLam Name PTerm PTerm
434 | PLam Name PTerm PTerm
424 | PPi Plicity Name PTerm PTerm
435 | PPi Plicity Name PTerm PTerm
425− | PLet Name PTerm PTerm PTerm
436+ | PLet Name PTerm PTerm PTerm
426− | PTyped PTerm PTerm -- term with explicit type
437+ | PTyped PTerm PTerm -- ^ Term with explicit type
427 | PApp FC PTerm [PArg]
438 | PApp FC PTerm [PArg]
428 | PCase FC PTerm [(PTerm, PTerm)]
439 | PCase FC PTerm [(PTerm, PTerm)]
429 | PTrue FC
440 | PTrue FC
@@ -434,7 +445,7 @@ data PTerm = PQuote Raw
434 | PPair FC PTerm PTerm
445 | PPair FC PTerm PTerm
435 | PDPair FC PTerm PTerm PTerm
446 | PDPair FC PTerm PTerm PTerm
436 | PAlternative Bool [PTerm] -- True if only one may work
447 | PAlternative Bool [PTerm] -- True if only one may work
437− | PHidden PTerm -- irrelevant or hidden pattern
448+ | PHidden PTerm -- ^ Irrelevant or hidden pattern
439 | PConstant Const
450 | PConstant Const
440 | Placeholder
451 | Placeholder
@@ -442,11 +453,11 @@ data PTerm = PQuote Raw
442 | PIdiom FC PTerm
453 | PIdiom FC PTerm
443 | PReturn FC
454 | PReturn FC
444 | PMetavar Name
455 | PMetavar Name
445− | PProof [PTactic]
456+ | PProof [PTactic] -- ^ Proof script
446− | PTactics [PTactic] -- as PProof, but no auto solving
457+ | PTactics [PTactic] -- ^ As PProof, but no auto solving
447− | PElabError Err -- error to report on elaboration
458+ | PElabError Err -- ^ Error to report on elaboration
448− | PImpossible -- special case for declaring when an LHS can't typecheck
459+ | PImpossible -- ^ Special case for declaring when an LHS can't typecheck
449− | PCoerced PTerm -- to mark a coerced argument, so as not to coerce twice
460+ | PCoerced PTerm -- ^ To mark a coerced argument, so as not to coerce twice
450 deriving Eq
461 deriving Eq
452deriving instance Binary PTerm
463deriving instance Binary PTerm