mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-11-24 04:43:25 +03:00
Allow setting logging mid term
Sometimes this makes debugging easier since the logging is more localised.
This commit is contained in:
parent
6beb6aa7c0
commit
7ff1e6275f
@ -297,11 +297,13 @@ tail [] impossible
|
|||||||
tail (x :: xs) = xs
|
tail (x :: xs) = xs
|
||||||
|
|
||||||
||| Attempt to get the head of a list. If the list is empty, return `Nothing`.
|
||| Attempt to get the head of a list. If the list is empty, return `Nothing`.
|
||||||
|
export
|
||||||
head' : List a -> Maybe a
|
head' : List a -> Maybe a
|
||||||
head' [] = Nothing
|
head' [] = Nothing
|
||||||
head' (x::xs) = Just x
|
head' (x::xs) = Just x
|
||||||
|
|
||||||
||| Attempt to get the tail of a list. If the list is empty, return `Nothing`.
|
||| Attempt to get the tail of a list. If the list is empty, return `Nothing`.
|
||||||
|
export
|
||||||
tail' : List a -> Maybe (List a)
|
tail' : List a -> Maybe (List a)
|
||||||
tail' [] = Nothing
|
tail' [] = Nothing
|
||||||
tail' (x::xs) = Just xs
|
tail' (x::xs) = Just xs
|
||||||
|
@ -524,11 +524,11 @@ searchType {vars} fc rigc defaults trying depth def checkdets top env target
|
|||||||
-- Core (Term vars)
|
-- Core (Term vars)
|
||||||
Core.Unify.search fc rigc defaults depth def top env
|
Core.Unify.search fc rigc defaults depth def top env
|
||||||
= do defs <- get Ctxt
|
= do defs <- get Ctxt
|
||||||
logTermNF 2 "Initial target: " env top
|
logTermNF 3 "Initial target: " env top
|
||||||
log 2 $ "Running search with defaults " ++ show defaults
|
log 3 $ "Running search with defaults " ++ show defaults
|
||||||
tm <- searchType fc rigc defaults [] depth def
|
tm <- searchType fc rigc defaults [] depth def
|
||||||
True (abstractEnvType fc env top) env
|
True (abstractEnvType fc env top) env
|
||||||
top
|
top
|
||||||
logTermNF 2 "Result" env tm
|
logTermNF 3 "Result" env tm
|
||||||
defs <- get Ctxt
|
defs <- get Ctxt
|
||||||
pure tm
|
pure tm
|
||||||
|
@ -329,8 +329,8 @@ mutual
|
|||||||
desugarB side ps (PApp fc (PRef fc (UN "rangeFrom")) start)
|
desugarB side ps (PApp fc (PRef fc (UN "rangeFrom")) start)
|
||||||
Just n =>
|
Just n =>
|
||||||
desugarB side ps (PApp fc (PApp fc (PRef fc (UN "rangeFromThen")) start) n)
|
desugarB side ps (PApp fc (PApp fc (PRef fc (UN "rangeFromThen")) start) n)
|
||||||
desugarB side ps (PUnifyLog fc tm)
|
desugarB side ps (PUnifyLog fc lvl tm)
|
||||||
= pure $ IUnifyLog fc !(desugarB side ps tm)
|
= pure $ IUnifyLog fc lvl !(desugarB side ps tm)
|
||||||
|
|
||||||
desugarUpdate : {auto s : Ref Syn SyntaxInfo} ->
|
desugarUpdate : {auto s : Ref Syn SyntaxInfo} ->
|
||||||
{auto b : Ref Bang BangData} ->
|
{auto b : Ref Bang BangData} ->
|
||||||
|
@ -358,10 +358,11 @@ mutual
|
|||||||
end <- location
|
end <- location
|
||||||
pure (PIdiom (MkFC fname start end) e)
|
pure (PIdiom (MkFC fname start end) e)
|
||||||
<|> do start <- location
|
<|> do start <- location
|
||||||
symbol "%"; exactIdent "unifyLog"
|
symbol "%"; exactIdent "logging"
|
||||||
|
lvl <- intLit
|
||||||
e <- expr pdef fname indents
|
e <- expr pdef fname indents
|
||||||
end <- location
|
end <- location
|
||||||
pure (PUnifyLog (MkFC fname start end) e)
|
pure (PUnifyLog (MkFC fname start end) (cast lvl) e)
|
||||||
|
|
||||||
multiplicity : EmptyRule (Maybe Integer)
|
multiplicity : EmptyRule (Maybe Integer)
|
||||||
multiplicity
|
multiplicity
|
||||||
|
@ -230,7 +230,7 @@ mutual
|
|||||||
toPTerm p (IUnquote fc tm) = pure (PUnquote fc !(toPTerm argPrec tm))
|
toPTerm p (IUnquote fc tm) = pure (PUnquote fc !(toPTerm argPrec tm))
|
||||||
toPTerm p (IRunElab fc tm) = pure (PRunElab fc !(toPTerm argPrec tm))
|
toPTerm p (IRunElab fc tm) = pure (PRunElab fc !(toPTerm argPrec tm))
|
||||||
|
|
||||||
toPTerm p (IUnifyLog fc tm) = toPTerm p tm
|
toPTerm p (IUnifyLog fc _ tm) = toPTerm p tm
|
||||||
toPTerm p (Implicit fc True) = pure (PImplicit fc)
|
toPTerm p (Implicit fc True) = pure (PImplicit fc)
|
||||||
toPTerm p (Implicit fc False) = pure (PInfer fc)
|
toPTerm p (Implicit fc False) = pure (PInfer fc)
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ mutual
|
|||||||
PRangeStream : FC -> PTerm -> Maybe PTerm -> PTerm
|
PRangeStream : FC -> PTerm -> Maybe PTerm -> PTerm
|
||||||
|
|
||||||
-- Debugging
|
-- Debugging
|
||||||
PUnifyLog : FC -> PTerm -> PTerm
|
PUnifyLog : FC -> Nat -> PTerm -> PTerm
|
||||||
|
|
||||||
-- TODO: 'with' disambiguation
|
-- TODO: 'with' disambiguation
|
||||||
|
|
||||||
@ -485,7 +485,7 @@ mutual
|
|||||||
= "[" ++ showPrec d start ++ " .. ]"
|
= "[" ++ showPrec d start ++ " .. ]"
|
||||||
showPrec d (PRangeStream _ start (Just next))
|
showPrec d (PRangeStream _ start (Just next))
|
||||||
= "[" ++ showPrec d start ++ ", " ++ showPrec d next ++ " .. ]"
|
= "[" ++ showPrec d start ++ ", " ++ showPrec d next ++ " .. ]"
|
||||||
showPrec d (PUnifyLog _ tm) = showPrec d tm
|
showPrec d (PUnifyLog _ lvl tm) = showPrec d tm
|
||||||
|
|
||||||
public export
|
public export
|
||||||
record IFaceInfo where
|
record IFaceInfo where
|
||||||
|
@ -5,6 +5,7 @@ import Core.Core
|
|||||||
import Core.Env
|
import Core.Env
|
||||||
import Core.Metadata
|
import Core.Metadata
|
||||||
import Core.Normalise
|
import Core.Normalise
|
||||||
|
import Core.Options
|
||||||
-- import Core.Reflect
|
-- import Core.Reflect
|
||||||
import Core.Unify
|
import Core.Unify
|
||||||
import Core.TT
|
import Core.TT
|
||||||
@ -186,11 +187,12 @@ checkTerm rig elabinfo nest env (IType fc) exp
|
|||||||
|
|
||||||
checkTerm rig elabinfo nest env (IHole fc str) exp
|
checkTerm rig elabinfo nest env (IHole fc str) exp
|
||||||
= checkHole rig elabinfo nest env fc str exp
|
= checkHole rig elabinfo nest env fc str exp
|
||||||
checkTerm rig elabinfo nest env (IUnifyLog fc tm) exp
|
checkTerm rig elabinfo nest env (IUnifyLog fc n tm) exp
|
||||||
= do ust <- get UST
|
= do opts <- getSession
|
||||||
put UST (record { logging = True } ust)
|
let lvl = logLevel opts
|
||||||
|
setLogLevel n
|
||||||
r <- check rig elabinfo nest env tm exp
|
r <- check rig elabinfo nest env tm exp
|
||||||
put UST ust
|
setLogLevel lvl
|
||||||
pure r
|
pure r
|
||||||
checkTerm rig elabinfo nest env (Implicit fc b) (Just gexpty)
|
checkTerm rig elabinfo nest env (Implicit fc b) (Just gexpty)
|
||||||
= do nm <- genName "_"
|
= do nm <- genName "_"
|
||||||
|
@ -97,7 +97,7 @@ mutual
|
|||||||
IType : FC -> RawImp
|
IType : FC -> RawImp
|
||||||
IHole : FC -> String -> RawImp
|
IHole : FC -> String -> RawImp
|
||||||
|
|
||||||
IUnifyLog : FC -> RawImp -> RawImp
|
IUnifyLog : FC -> Nat -> RawImp -> RawImp
|
||||||
-- An implicit value, solved by unification, but which will also be
|
-- An implicit value, solved by unification, but which will also be
|
||||||
-- bound (either as a pattern variable or a type variable) if unsolved
|
-- bound (either as a pattern variable or a type variable) if unsolved
|
||||||
-- at the end of elaborator
|
-- at the end of elaborator
|
||||||
@ -164,7 +164,7 @@ mutual
|
|||||||
show (IRunElab fc tm) = "(%runelab " ++ show tm ++ ")"
|
show (IRunElab fc tm) = "(%runelab " ++ show tm ++ ")"
|
||||||
show (IPrimVal fc c) = show c
|
show (IPrimVal fc c) = show c
|
||||||
show (IHole _ x) = "?" ++ x
|
show (IHole _ x) = "?" ++ x
|
||||||
show (IUnifyLog _ x) = "(%unifyLog " ++ show x ++ ")"
|
show (IUnifyLog _ lvl x) = "(%logging " ++ show lvl ++ " " ++ show x ++ ")"
|
||||||
show (IType fc) = "%type"
|
show (IType fc) = "%type"
|
||||||
show (Implicit fc True) = "_"
|
show (Implicit fc True) = "_"
|
||||||
show (Implicit fc False) = "?"
|
show (Implicit fc False) = "?"
|
||||||
@ -542,7 +542,7 @@ getFC (IRewrite x _ _) = x
|
|||||||
getFC (ICoerced x _) = x
|
getFC (ICoerced x _) = x
|
||||||
getFC (IPrimVal x _) = x
|
getFC (IPrimVal x _) = x
|
||||||
getFC (IHole x _) = x
|
getFC (IHole x _) = x
|
||||||
getFC (IUnifyLog x _) = x
|
getFC (IUnifyLog x _ _) = x
|
||||||
getFC (IType x) = x
|
getFC (IType x) = x
|
||||||
getFC (IBindVar x _) = x
|
getFC (IBindVar x _) = x
|
||||||
getFC (IBindHere x _ _) = x
|
getFC (IBindHere x _ _) = x
|
||||||
@ -641,7 +641,7 @@ mutual
|
|||||||
= do tag 26; toBuf b fc
|
= do tag 26; toBuf b fc
|
||||||
toBuf b (IHole fc y)
|
toBuf b (IHole fc y)
|
||||||
= do tag 27; toBuf b fc; toBuf b y
|
= do tag 27; toBuf b fc; toBuf b y
|
||||||
toBuf b (IUnifyLog fc x) = toBuf b x
|
toBuf b (IUnifyLog fc lvl x) = toBuf b x
|
||||||
|
|
||||||
toBuf b (Implicit fc i)
|
toBuf b (Implicit fc i)
|
||||||
= do tag 28; toBuf b fc; toBuf b i
|
= do tag 28; toBuf b fc; toBuf b i
|
||||||
|
Loading…
Reference in New Issue
Block a user