@@ -90,8 +90,9 @@ data IOption = IOption { opt_logLevel :: Int,
9090 opt_autoImport :: [FilePath], -- ^ e.g. Builtins+Prelude
9191 opt_optimise :: [Optimisation],
9292 opt_printdepth :: Maybe Int,
93− opt_evaltypes :: Bool -- ^ normalise types in :t
94− }
93+ opt_evaltypes :: Bool, -- ^ normalise types in :t
94+ opt_desugarnats :: Bool
95+ }
9596 deriving (Show, Eq)
9697
9798defaultOpts = IOption { opt_logLevel = 0
@@ -117,10 +118,12 @@ defaultOpts = IOption { opt_logLevel = 0
117118 , opt_optimise = defaultOptimise
118119 , opt_printdepth = Just 5000
119120 , opt_evaltypes = True
121+ , opt_desugarnats = False
120122 }
121123
122124data PPOption = PPOption {
123125 ppopt_impl :: Bool -- ^^ whether to show implicits
126+ , ppopt_desugarnats :: Bool
124127 , ppopt_pinames :: Bool -- ^^ whether to show names in pi bindings
125128 , ppopt_depth :: Maybe Int
126129} deriving (Show)
@@ -133,12 +136,14 @@ defaultOptimise = [PETransform]
133136-- | Pretty printing options with default verbosity.
134137defaultPPOption :: PPOption
135138defaultPPOption = PPOption { ppopt_impl = False,
139+ ppopt_desugarnats = False,
136140 ppopt_pinames = False,
137141 ppopt_depth = Just 200 }
138142
139143-- | Pretty printing options with the most verbosity.
140144verbosePPOption :: PPOption
141145verbosePPOption = PPOption { ppopt_impl = True,
146+ ppopt_desugarnats = True,
142147 ppopt_pinames = True,
143148 ppopt_depth = Just 200 }
144149
@@ -147,7 +152,8 @@ ppOption :: IOption -> PPOption
147152ppOption opt = PPOption {
148153 ppopt_impl = opt_showimp opt,
149154 ppopt_pinames = False,
150− ppopt_depth = opt_printdepth opt
155+ ppopt_depth = opt_printdepth opt,
156+ ppopt_desugarnats = opt_desugarnats opt
151157}
152158
153159-- | Get pretty printing options from an idris state record.
@@ -503,6 +509,7 @@ data Opt = Filename String
503509 | AutoSolve -- ^ Automatically issue "solve" tactic in interactive prover
504510 | UseConsoleWidth ConsoleWidth
505511 | DumpHighlights
512+ | DesugarNats
506513 deriving (Show, Eq)
507514
508515data ElabShellCmd = EQED | EAbandon | EUndo | EProofState | EProofTerm
@@ -1653,7 +1660,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe (ppopt_depth ppo) startPrec bnd
16531660 prettySe d p bnd (PPatvar fc n) = pretty n
16541661 prettySe d p bnd e
16551662 | 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))
16571664 prettySe d p bnd (PRef fc _ n) = prettyName True (ppopt_impl ppo) bnd n
16581665 prettySe d p bnd (PLam fc n nfc ty sc) =
16591666 depth d . bracket p startPrec . group . align . hang 2 $
@@ -1944,15 +1951,20 @@ pprintPTerm ppo bnd docArgs infixes = prettySe (ppopt_depth ppo) startPrec bnd
19441951
19451952 natns = "Prelude.Nat."
19461953
1947− snat :: Maybe Int -> Int -> PTerm -> Maybe Integer
1948− snat (Just x) _ _ | x <= 0 = Nothing
1949− snat d p (PRef _ _ z)
1950− | show z == (natns++"Z") || show z == "Z" = Just 0
1951− snat d p (PApp _ s [PExp {getTm=n}])
1952− | show s == (natns++"S") || show s == "S",
1953− Just n' <- snat (decD d) p n
1954− = Just $ 1 + n'
1955− snat _ _ _ = Nothing
1954+ snat :: PPOption -> Maybe Int -> Int -> PTerm -> Maybe Integer
1955+ snat ppo d p e
1956+ | ppopt_desugarnats ppo = Nothing
1957+ | otherwise = snat' d p e
1958+ where
1959+ snat' :: Maybe Int -> Int -> PTerm -> Maybe Integer
1960+ snat' (Just x) _ _ | x <= 0 = Nothing
1961+ snat' d p (PRef _ _ z)
1962+ | show z == (natns++"Z") || show z == "Z" = Just 0
1963+ snat' d p (PApp _ s [PExp {getTm=n}])
1964+ | show s == (natns++"S") || show s == "S",
1965+ Just n' <- snat' (decD d) p n
1966+ = Just $ 1 + n'
1967+ snat' _ _ _ = Nothing
19561968
19571969 bracket outer inner doc
19581970 | outer > inner = lparen <> doc <> rparen