@@ -42,8 +42,8 @@ module Idris.Core.TT(
4242 , intTyName, isInjective, isTypeConst, lookupCtxt
4343 , lookupCtxtExact, lookupCtxtName, mapCtxt, mkApp, nativeTyWidth
4444 , nextName, noOccurrence, nsroot, occurrences
45− , pEraseType, pmap, pprintRaw, pprintTT, prettyEnv, psubst, pToV
46− , pToVs, pureTerm, raw_apply, raw_unapply, refsIn, safeForget
45+ , pEraseType, pmap, pprintRaw, pprintTT, pprintTTClause, prettyEnv, psubst
46+ , pToV, pToVs, pureTerm, raw_apply, raw_unapply, refsIn, safeForget
4747 , safeForgetEnv, showCG, showEnv, showEnvDbg, showSep
4848 , sInstanceN, sMN, sNS, spanFC, str, subst, substNames, substTerm
4949 , substV, sUN, tcname, termSmallerThan, tfail, thead, tnull
@@ -54,8 +54,8 @@ module Idris.Core.TT(
5454-- Work around AMP without CPP
5555import Prelude (Eq(..), Show(..), Ord(..), Functor(..), Monad(..), String, Int,
5656 Integer, Ordering(..), Maybe(..), Num(..), Bool(..), Enum(..),
57− Read(..), FilePath, Double, (&&), (||), ($), (.), div, error, fst,
58− snd, not, mod, read, otherwise)
57+ Read(..), FilePath, Double, (&&), (||), ($), (.), div, error, flip,
58+ fst, snd, not, mod, read, otherwise)
5959
6060import Control.Applicative (Applicative (..), Alternative)
6161import qualified Control.Applicative as A (Alternative (..))
@@ -1811,6 +1811,23 @@ pprintTT bound tm = pp startPrec bound tm
18111811 | outer > inner = lparen <> doc <> rparen
18121812 | otherwise = doc
18131813
1814+pprintTTClause :: [(Name, Type)] -> Term -> Term -> Doc OutputAnnotation
1815+pprintTTClause pvars lhs rhs =
1816+ vars pvars . group . align $
1817+ pprintTT (map fst pvars) lhs <$>
1818+ text "↦" <$>
1819+ (pprintTT (map fst pvars) rhs)
1820+ where vars [] terms = terms
1821+ vars (v:vs) terms =
1822+ annotate AnnKeyword (text "var") <+>
1823+ group (align (sep (punctuate comma (reverse (bindVars [] (v:vs)))))) <+>
1824+ annotate AnnKeyword (text ".") <$>
1825+ indent 2 terms
1826+ bindVars _ [] = []
1827+ bindVars ns ((n, ty):vs) =
1828+ bindingOf n False <+> colon <+> pprintTT ns ty : bindVars (n:ns) vs
1829+
1830+
18141831-- | Pretty-print a raw term.
18151832pprintRaw :: [Name] -- ^ Bound names, for highlighting
18161833 -> Raw -- ^ The term to pretty-print