@@ -29,7 +29,7 @@ data EvalOpt = Spec | HNF | Simplify Bool | AtREPL
29initEval = ES []
29initEval = ES []
31-- VALUES (as HOAS) ---------------------------------------------------------
31-- VALUES (as HOAS) ---------------------------------------------------------
32−
32+-- | A HOAS representation of values
33data Value = VP NameType Name Value
33data Value = VP NameType Name Value
35 | VBind Name (Binder Value) (Value -> Eval Value)
35 | VBind Name (Binder Value) (Value -> Eval Value)
@@ -62,7 +62,7 @@ instance Show (a -> b) where
62-- i.e. it's an intermediate environment that we have while type checking or
62-- i.e. it's an intermediate environment that we have while type checking or
63-- while building a proof.
63-- while building a proof.
65−-- Normalise fully type checked terms (so, assume all names/let bindings resolved)
65+-- | Normalise fully type checked terms (so, assume all names/let bindings resolved)
66normaliseC :: Context -> Env -> TT Name -> TT Name
66normaliseC :: Context -> Env -> TT Name -> TT Name
67normaliseC ctxt env t
67normaliseC ctxt env t
68 = evalState (do val <- eval False ctxt [] env t []
68 = evalState (do val <- eval False ctxt [] env t []
@@ -86,9 +86,8 @@ specialise ctxt env limits t
86 = evalState (do val <- eval False ctxt limits (map finalEntry env) (finalise t) []
86 = evalState (do val <- eval False ctxt limits (map finalEntry env) (finalise t) []
87 quote 0 val) (initEval { limited = limits })
87 quote 0 val) (initEval { limited = limits })
89−-- Like normalise, but we only reduce functions that are marked as okay to
89+-- | Like normalise, but we only reduce functions that are marked as okay to
90-- inline (and probably shouldn't reduce lets?)
90-- inline (and probably shouldn't reduce lets?)
92simplify :: Context -> Bool -> Env -> TT Name -> TT Name
91simplify :: Context -> Bool -> Env -> TT Name -> TT Name
93simplify ctxt runtime env t
92simplify ctxt runtime env t
94 = evalState (do val <- eval False ctxt [(UN "lazy", 0),
93 = evalState (do val <- eval False ctxt [(UN "lazy", 0),
@@ -98,6 +97,7 @@ simplify ctxt runtime env t
98 [Simplify runtime]
97 [Simplify runtime]
99 quote 0 val) initEval
98 quote 0 val) initEval
100+-- | Reduce a term to head normal form
101hnf :: Context -> Env -> TT Name -> TT Name
101hnf :: Context -> Env -> TT Name -> TT Name
102hnf ctxt env t
102hnf ctxt env t
103 = evalState (do val <- eval False ctxt []
103 = evalState (do val <- eval False ctxt []
@@ -130,9 +130,8 @@ usable s n ns = case lookup n ns of
130 _ -> if s then (True, (n, 0) : filter (\ (n', _) -> n/=n') ns)
130 _ -> if s then (True, (n, 0) : filter (\ (n', _) -> n/=n') ns)
131 else (True, (n, 100) : filter (\ (n', _) -> n/=n') ns)
131 else (True, (n, 100) : filter (\ (n', _) -> n/=n') ns)
133−-- Evaluate in a context of locally named things (i.e. not de Bruijn indexed,
133+-- | Evaluate in a context of locally named things (i.e. not de Bruijn indexed,
134-- such as we might have during construction of a proof)
134-- such as we might have during construction of a proof)
136eval :: Bool -> Context -> [(Name, Int)] -> Env -> TT Name ->
135eval :: Bool -> Context -> [(Name, Int)] -> Env -> TT Name ->
137 [EvalOpt] -> Eval Value
136 [EvalOpt] -> Eval Value
138eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
137eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
@@ -576,7 +575,7 @@ spec ctxt statics genv tm = error "spec undefined"
577-- CONTEXTS -----------------------------------------------------------------
576-- CONTEXTS -----------------------------------------------------------------
579−{- A definition is either a simple function (just an expression with a type),
578+{-| A definition is either a simple function (just an expression with a type),
580 a constant, which could be a data or type constructor, an axiom or as an
579 a constant, which could be a data or type constructor, an axiom or as an
581 yet undefined function, or an Operator.
580 yet undefined function, or an Operator.
582 An Operator is a function which explains how to reduce.
581 An Operator is a function which explains how to reduce.
@@ -620,12 +619,14 @@ instance Binary (a -> b) where
620data Accessibility = Public | Frozen | Hidden
619data Accessibility = Public | Frozen | Hidden
621 deriving (Show, Eq)
620 deriving (Show, Eq)
622+-- | The result of totality checking
623−data Totality = Total [Int] -- well-founded arguments
623+data Totality = Total [Int] -- ^ well-founded arguments
624− | Productive
624+ | Productive -- ^ productive
625 | Partial PReason
625 | Partial PReason
626 | Unchecked
626 | Unchecked
627 deriving Eq
627 deriving Eq
629+-- | Reasons why a function may not be total
629data PReason = Other [Name] | Itself | NotCovering | NotPositive | UseUndef Name
630data PReason = Other [Name] | Itself | NotCovering | NotPositive | UseUndef Name
630 | BelieveMe | Mutual [Name] | NotProductive
631 | BelieveMe | Mutual [Name] | NotProductive
631 deriving (Show, Eq)
632 deriving (Show, Eq)