@@ -2,7 +2,7 @@
2 PatternGuards #-}
2 PatternGuards #-}
3{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
3{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
5−module Idris.Core.Evaluate(normalise, normaliseTrace, normaliseC, normaliseAll,
5+module Idris.Core.Evaluate(normalise, normaliseTrace, normaliseC, normaliseAll, toValue, quoteTerm,
6 rt_simplify, simplify, specialise, hnf, convEq, convEq',
6 rt_simplify, simplify, specialise, hnf, convEq, convEq',
7 Def(..), CaseInfo(..), CaseDefs(..),
7 Def(..), CaseInfo(..), CaseDefs(..),
8 Accessibility(..), Totality(..), PReason(..), MetaInformation(..),
8 Accessibility(..), Totality(..), PReason(..), MetaInformation(..),
@@ -13,7 +13,7 @@ module Idris.Core.Evaluate(normalise, normaliseTrace, normaliseC, normaliseAll,
13 lookupP, lookupP_all, lookupDef, lookupNameDef, lookupDefExact, lookupDefAcc, lookupDefAccExact, lookupVal,
13 lookupP, lookupP_all, lookupDef, lookupNameDef, lookupDefExact, lookupDefAcc, lookupDefAccExact, lookupVal,
14 mapDefCtxt,
14 mapDefCtxt,
15 lookupTotal, lookupNameTotal, lookupMetaInformation, lookupTyEnv, isTCDict, isDConName, canBeDConName, isTConName, isConName, isFnName,
15 lookupTotal, lookupNameTotal, lookupMetaInformation, lookupTyEnv, isTCDict, isDConName, canBeDConName, isTConName, isConName, isFnName,
16− Value(..), initEval, uniqueNameCtxt, uniqueBindersCtxt, definitions,
16+ Value(..), Quote(..), initEval, uniqueNameCtxt, uniqueBindersCtxt, definitions,
17 isUniverse) where
17 isUniverse) where
19import Debug.Trace
19import Debug.Trace
@@ -92,6 +92,13 @@ normaliseTrace tr ctxt env t
92 = evalState (do val <- eval tr ctxt [] (map finalEntry env) (finalise t) []
92 = evalState (do val <- eval tr ctxt [] (map finalEntry env) (finalise t) []
93 quote 0 val) initEval
93 quote 0 val) initEval
95+toValue :: Context -> Env -> TT Name -> Value
97+ = evalState (eval False ctxt [] (map finalEntry env) t []) initEval
99+quoteTerm :: Value -> TT Name
100+quoteTerm val = evalState (quote 0 val) initEval
95-- Return a specialised name, and an updated list of reductions available,
102-- Return a specialised name, and an updated list of reductions available,
96-- so that the caller can tell how much specialisation was achieved.
103-- so that the caller can tell how much specialisation was achieved.
97specialise :: Context -> Env -> [(Name, Int)] -> TT Name ->
104specialise :: Context -> Env -> [(Name, Int)] -> TT Name ->