@@ -17,7 +17,7 @@ import Idris.Core.Evaluate (Def(TyDecl), initContext, lookupDefExact, lookupTyEx
1717import Idris.Core.TT
1818
1919import Idris.AbsSyntaxTree (ArgOpt(..),ElabD, IState(tt_ctxt, idris_implicits,idris_datatypes),
20− PArg'(..), PArg, PTactic, PTactic'(..), PTerm(..),
20+ PArg'(..), PArg, PTactic, PTactic'(..), PTerm(..), Fixity (..),
2121 initEState, pairCon, pairTy)
2222import Idris.Delaborate (delab)
2323
@@ -398,6 +398,19 @@ claimTy n ty = do n' <- getNameFrom n
398398 claim n' ty
399399 return n'
400400
401+intToReflectedNat :: Int -> Raw
402+intToReflectedNat i = if i <= 0
403+ then Var (natN "Z")
404+ else RApp (Var (natN "S")) (intToReflectedNat (i - 1))
405+ where natN :: String -> Name
406+ natN n = sNS (sUN n) ["Nat", "Prelude"]
407+
408+reflectFixity :: Fixity -> Raw
409+reflectFixity (Infixl p) = RApp (Var (tacN "Infixl")) (intToReflectedNat p)
410+reflectFixity (Infixr p) = RApp (Var (tacN "Infixr")) (intToReflectedNat p)
411+reflectFixity (InfixN p) = RApp (Var (tacN "InfixN")) (intToReflectedNat p)
412+reflectFixity (PrefixN p) = RApp (Var (tacN "PrefixN")) (intToReflectedNat p)
413+
401414-- | Convert a reflected term to a more suitable form for pattern-matching.
402415-- In particular, the less-interesting bits are elaborated to _ patterns. This
403416-- happens to NameTypes, universe levels, names that are bound but not used,