@@ -90,8 +90,9 @@ data IOption = IOption { opt_logLevel :: Int,
90 opt_autoImport :: [FilePath], -- ^ e.g. Builtins+Prelude
90 opt_autoImport :: [FilePath], -- ^ e.g. Builtins+Prelude
91 opt_optimise :: [Optimisation],
91 opt_optimise :: [Optimisation],
92 opt_printdepth :: Maybe Int,
92 opt_printdepth :: Maybe Int,
93− opt_evaltypes :: Bool -- ^ normalise types in :t
93+ opt_evaltypes :: Bool, -- ^ normalise types in :t
94+ opt_desugarnats :: Bool
95 deriving (Show, Eq)
96 deriving (Show, Eq)
97defaultOpts = IOption { opt_logLevel = 0
98defaultOpts = IOption { opt_logLevel = 0
@@ -117,10 +118,12 @@ defaultOpts = IOption { opt_logLevel = 0
117 , opt_optimise = defaultOptimise
118 , opt_optimise = defaultOptimise
118 , opt_printdepth = Just 5000
119 , opt_printdepth = Just 5000
119 , opt_evaltypes = True
120 , opt_evaltypes = True
121+ , opt_desugarnats = False
122data PPOption = PPOption {
124data PPOption = PPOption {
123 ppopt_impl :: Bool -- ^^ whether to show implicits
125 ppopt_impl :: Bool -- ^^ whether to show implicits
126+ , ppopt_desugarnats :: Bool
124 , ppopt_pinames :: Bool -- ^^ whether to show names in pi bindings
127 , ppopt_pinames :: Bool -- ^^ whether to show names in pi bindings
125 , ppopt_depth :: Maybe Int
128 , ppopt_depth :: Maybe Int
126} deriving (Show)
129} deriving (Show)
@@ -133,12 +136,14 @@ defaultOptimise = [PETransform]
133-- | Pretty printing options with default verbosity.
136-- | Pretty printing options with default verbosity.
134defaultPPOption :: PPOption
137defaultPPOption :: PPOption
135defaultPPOption = PPOption { ppopt_impl = False,
138defaultPPOption = PPOption { ppopt_impl = False,
139+ ppopt_desugarnats = False,
136 ppopt_pinames = False,
140 ppopt_pinames = False,
137 ppopt_depth = Just 200 }
141 ppopt_depth = Just 200 }
139-- | Pretty printing options with the most verbosity.
143-- | Pretty printing options with the most verbosity.
140verbosePPOption :: PPOption
144verbosePPOption :: PPOption
141verbosePPOption = PPOption { ppopt_impl = True,
145verbosePPOption = PPOption { ppopt_impl = True,
146+ ppopt_desugarnats = True,
142 ppopt_pinames = True,
147 ppopt_pinames = True,
143 ppopt_depth = Just 200 }
148 ppopt_depth = Just 200 }
@@ -147,7 +152,8 @@ ppOption :: IOption -> PPOption
147ppOption opt = PPOption {
152ppOption opt = PPOption {
148 ppopt_impl = opt_showimp opt,
153 ppopt_impl = opt_showimp opt,
149 ppopt_pinames = False,
154 ppopt_pinames = False,
150− ppopt_depth = opt_printdepth opt
155+ ppopt_depth = opt_printdepth opt,
156+ ppopt_desugarnats = opt_desugarnats opt
153-- | Get pretty printing options from an idris state record.
159-- | Get pretty printing options from an idris state record.
@@ -503,6 +509,7 @@ data Opt = Filename String
503 | AutoSolve -- ^ Automatically issue "solve" tactic in interactive prover
509 | AutoSolve -- ^ Automatically issue "solve" tactic in interactive prover
504 | UseConsoleWidth ConsoleWidth
510 | UseConsoleWidth ConsoleWidth
505 | DumpHighlights
511 | DumpHighlights
506 deriving (Show, Eq)
513 deriving (Show, Eq)
508data ElabShellCmd = EQED | EAbandon | EUndo | EProofState | EProofTerm
515data ElabShellCmd = EQED | EAbandon | EUndo | EProofState | EProofTerm
@@ -1653,7 +1660,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe (ppopt_depth ppo) startPrec bnd
1653 prettySe d p bnd (PPatvar fc n) = pretty n
1660 prettySe d p bnd (PPatvar fc n) = pretty n
1654 prettySe d p bnd e
1661 prettySe d p bnd e
1655 | Just str <- slist d p bnd e = depth d $ str
1662 | Just str <- slist d p bnd e = depth d $ str
1656− | Just n <- snat d p e = depth d $ annotate (AnnData "Nat" "") (text (show n))
1663+ | Just n <- snat ppo d p e = depth d $ annotate (AnnData "Nat" "") (text (show n))
1657 prettySe d p bnd (PRef fc _ n) = prettyName True (ppopt_impl ppo) bnd n
1664 prettySe d p bnd (PRef fc _ n) = prettyName True (ppopt_impl ppo) bnd n
1658 prettySe d p bnd (PLam fc n nfc ty sc) =
1665 prettySe d p bnd (PLam fc n nfc ty sc) =
1659 depth d . bracket p startPrec . group . align . hang 2 $
1666 depth d . bracket p startPrec . group . align . hang 2 $
@@ -1944,15 +1951,20 @@ pprintPTerm ppo bnd docArgs infixes = prettySe (ppopt_depth ppo) startPrec bnd
1945 natns = "Prelude.Nat."
1952 natns = "Prelude.Nat."
1947− snat :: Maybe Int -> Int -> PTerm -> Maybe Integer
1954+ snat :: PPOption -> Maybe Int -> Int -> PTerm -> Maybe Integer
1956+ | ppopt_desugarnats ppo = Nothing
1957+ | otherwise = snat' d p e
1959+ snat' :: Maybe Int -> Int -> PTerm -> Maybe Integer
1948− snat (Just x) _ _ | x <= 0 = Nothing
1960+ snat' (Just x) _ _ | x <= 0 = Nothing
1949− snat d p (PRef _ _ z)
1961+ snat' d p (PRef _ _ z)
1950− | show z == (natns++"Z") || show z == "Z" = Just 0
1962+ | show z == (natns++"Z") || show z == "Z" = Just 0
1951− snat d p (PApp _ s [PExp {getTm=n}])
1963+ snat' d p (PApp _ s [PExp {getTm=n}])
1952− | show s == (natns++"S") || show s == "S",
1964+ | show s == (natns++"S") || show s == "S",
1953− Just n' <- snat (decD d) p n
1965+ Just n' <- snat' (decD d) p n
1954− = Just $ 1 + n'
1966+ = Just $ 1 + n'
1955− snat _ _ _ = Nothing
1967+ snat' _ _ _ = Nothing
1957 bracket outer inner doc
1969 bracket outer inner doc
1958 | outer > inner = lparen <> doc <> rparen
1970 | outer > inner = lparen <> doc <> rparen