1{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, DeriveFunctor,
2 TypeSynonymInstances, PatternGuards #-}
4module Idris.AbsSyntaxTree where
8import Core.Elaborate hiding (Tactic(..))
11import IRTS.CodegenCommon
13import Util.DynamicLinker
19import System.Console.Haskeline
22import Control.Monad.Trans.State.Strict
23import Control.Monad.Trans.Error
28import Data.Word (Word)
32data IOption = IOption { opt_logLevel :: Int,
34 opt_typeintype :: Bool,
36 opt_showimp :: Bool, -- ^^ show implicits
37 opt_errContext :: Bool,
41 opt_codegen :: Codegen,
42 opt_outputTy :: OutputType,
43 opt_ibcsubdir :: FilePath,
44 opt_importdirs :: [FilePath],
48 opt_cmdline :: [Opt] -- remember whole command line
52defaultOpts = IOption { opt_logLevel = 0
53 , opt_typecase = False
54 , opt_typeintype = False
57 , opt_errContext = False
62 , opt_outputTy = Executable
71data LanguageExt = TypeProviders | ErrorReflection deriving (Show, Eq, Read, Ord)
73-- | The output mode in use
74data OutputMode = RawOutput | IdeSlave Integer deriving Show
76-- TODO: Add 'module data' to IState, which can be saved out and reloaded quickly (i.e
77-- without typechecking).
78-- This will include all the functions and data declarations, plus fixity declarations
81-- | The global state used in the Idris monad
83 tt_ctxt :: Context, -- ^ All the currently defined names and their terms
84 idris_constraints :: [(UConstraint, FC)],
85 -- ^ A list of universe constraints and their corresponding source locations
86 idris_infixes :: [FixDecl], -- ^ Currently defined infix operators
87 idris_implicits :: Ctxt [PArg],
88 idris_statics :: Ctxt [Bool],
89 idris_classes :: Ctxt ClassInfo,
90 idris_dsls :: Ctxt DSL,
91 idris_optimisation :: Ctxt OptInfo,
92 idris_datatypes :: Ctxt TypeInfo,
93 idris_patdefs :: Ctxt ([([Name], Term, Term)], [PTerm]), -- not exported
94 -- ^ list of lhs/rhs, and a list of missing clauses
95 idris_flags :: Ctxt [FnOpt],
96 idris_callgraph :: Ctxt CGInfo, -- name, args used in each pos
97 idris_calledgraph :: Ctxt [Name],
98 idris_docstrings :: Ctxt String,
99 idris_totcheck :: [(FC, Name)],
101 idris_options :: IOption,
103 idris_lineapps :: [((FilePath, Int), PTerm)],
104 -- ^ Full application LHS on source line
105 idris_metavars :: [(Name, (Maybe Name, Int))], -- ^ The currently defined but not proven metavariables
106 idris_coercions :: [Name],
107 idris_transforms :: [(Term, Term)],
108 syntax_rules :: [Syntax],
109 syntax_keywords :: [String],
110 imported :: [FilePath], -- ^ The imported modules
111 idris_scprims :: [(Name, (Int, PrimFn))],
112 idris_objs :: [(Codegen, FilePath)],
113 idris_libs :: [(Codegen, String)],
114 idris_cgflags :: [(Codegen, String)],
115 idris_hdrs :: [(Codegen, String)],
116 proof_list :: [(Name, [String])],
117 errLine :: Maybe Int,
118 lastParse :: Maybe Name,
119 indent_stack :: [Int],
120 brace_stack :: [Maybe Int],
121 hide_list :: [(Name, Maybe Accessibility)],
122 default_access :: Accessibility,
123 default_total :: Bool,
124 ibc_write :: [IBCWrite],
125 compiled_so :: Maybe String,
126 idris_dynamic_libs :: [DynamicLib],
127 idris_language_extensions :: [LanguageExt],
128 idris_outputmode :: OutputMode,
129 idris_colourRepl :: Bool,
130 idris_colourTheme :: ColourTheme,
131 idris_outh :: Handle,
132 idris_errorhandlers :: [Name]
135data SizeChange = Smaller | Same | Bigger | Unknown
138deriving instance Binary SizeChange
141type SCGEntry = (Name, [Maybe (Int, SizeChange)])
143data CGInfo = CGInfo { argsdef :: [Name],
144 calls :: [(Name, [[Name]])],
150deriving instance Binary CGInfo
153primDefs = [UN "unsafePerformPrimIO",
154 UN "mkLazyForeignPrim",
158-- information that needs writing for the current module's .ibc file
159data IBCWrite = IBCFix FixDecl
163 | IBCInstance Bool Name Name
170 | IBCObj Codegen FilePath
171 | IBCLib Codegen String
172 | IBCCGFlag Codegen String
174 | IBCHeader Codegen String
175 | IBCAccess Name Accessibility
176 | IBCTotal Name Totality
177 | IBCFlags Name [FnOpt]
178 | IBCTrans (Term, Term)
182 | IBCDef Name -- i.e. main context
183 | IBCLineApp FilePath Int PTerm
186-- | The initial state for the compiler
188idrisInit = IState initContext [] [] emptyContext emptyContext emptyContext
189 emptyContext emptyContext emptyContext emptyContext
190 emptyContext emptyContext emptyContext emptyContext
191 [] "" defaultOpts 6 [] [] [] [] [] [] [] [] [] [] [] []
192 [] Nothing Nothing [] [] [] Hidden False [] Nothing [] [] RawOutput
193 True defaultTheme stdout []
195-- | The monad for the main REPL - reading and processing files and updating
196-- global state (hence the IO inner monad).
197--type Idris = WriterT [Either String (IO ())] (State IState a))
198type Idris = StateT IState (ErrorT Err IO)
200-- Commands in the REPL
219 | ChangeDirectory FilePath
222 | Compile Codegen String
227 | AddProof (Maybe Name)
240 | DynamicLink FilePath
245 | CaseSplit Name PTerm
246 | CaseSplitAt Bool Int Name
247 | AddClauseFrom Bool Int Name
248 | AddProofClauseFrom Bool Int Name
249 | AddMissing Bool Int Name
250 | MakeWith Bool Int Name
251 | DoProofSearch Bool Int Name [Name]
255 | SetColour ColourType IdrisColour
259data Opt = Filename String
293 | OutputTy OutputType
294 | Extension LanguageExt
295 | InterpretScript String
296 | TargetTriple String
302-- Parsed declarations
304data Fixity = Infixl { prec :: Int }
305 | Infixr { prec :: Int }
306 | InfixN { prec :: Int }
307 | PrefixN { prec :: Int }
310deriving instance Binary Fixity
313instance Show Fixity where
314 show (Infixl i) = "infixl " ++ show i
315 show (Infixr i) = "infixr " ++ show i
316 show (InfixN i) = "infix " ++ show i
317 show (PrefixN i) = "prefix " ++ show i
319data FixDecl = Fix Fixity String
322instance Show FixDecl where
323 show (Fix f s) = show f ++ " " ++ s
326deriving instance Binary FixDecl
329instance Ord FixDecl where
330 compare (Fix x _) (Fix y _) = compare (prec x) (prec y)
333data Static = Static | Dynamic
336deriving instance Binary Static
339-- Mark bindings with their explicitness, and laziness
340data Plicity = Imp { plazy :: Bool,
344 | Exp { plazy :: Bool,
348 | Constraint { plazy :: Bool,
351 | TacImp { plazy :: Bool,
358deriving instance Binary Plicity
361impl = Imp False Dynamic "" False
362expl = Exp False Dynamic "" False
363expl_param = Exp False Dynamic "" True
364constraint = Constraint False Dynamic ""
365tacimpl t = TacImp False Dynamic t ""
367data FnOpt = Inlinable -- always evaluate when simplifying
368 | TotalFn | PartialFn
369 | Coinductive | AssertTotal
370 | Dictionary -- type class dictionary, eval only when
371 -- a function argument, and further evaluation resutls
372 | Implicit -- implicit coercion
373 | CExport String -- export, with a C name
374 | ErrorHandler -- ^^ an error handler for use with the ErrorReflection extension
375 | Reflection -- a reflecting function, compile-time only
376 | Specialise [(Name, Maybe Int)] -- specialise it, freeze these names
379deriving instance Binary FnOpt
384inlinable :: FnOpts -> Bool
385inlinable = elem Inlinable
387dictionary :: FnOpts -> Bool
388dictionary = elem Dictionary
390-- | Top-level declarations such as compiler directives, definitions,
391-- datatypes and typeclasses.
393 = PFix FC Fixity [String] -- ^ Fixity declaration
394 | PTy String SyntaxInfo FC FnOpts Name t -- ^ Type declaration
395 | PPostulate String SyntaxInfo FC FnOpts Name t -- ^ Postulate
396 | PClauses FC FnOpts Name [PClause' t] -- ^ Pattern clause
397 | PCAF FC Name t -- ^ Top level constant
398 | PData String SyntaxInfo FC Bool (PData' t) -- ^ Data declaration. The Bool argument is True for codata.
399 | PParams FC [(Name, t)] [PDecl' t] -- ^ Params block
400 | PNamespace String [PDecl' t] -- ^ New namespace
401 | PRecord String SyntaxInfo FC Name t String Name t -- ^ Record declaration
402 | PClass String SyntaxInfo FC
405 [(Name, t)] -- parameters
406 [PDecl' t] -- declarations
407 -- ^ Type class: arguments are documentation, syntax info, source location, constraints,
408 -- class name, parameters, method declarations
409 | PInstance SyntaxInfo FC [t] -- constraints
412 t -- full instance type
413 (Maybe Name) -- explicit name
415 -- ^ Instance declaration: arguments are syntax info, source location, constraints,
416 -- class name, parameters, full instance type, optional explicit name, and definitions
417 | PDSL Name (DSL' t) -- ^ DSL declaration
418 | PSyntax FC Syntax -- ^ Syntax definition
419 | PMutual FC [PDecl' t] -- ^ Mutual block
420 | PDirective (Idris ()) -- ^ Compiler directive. The parser inserts the corresponding action in the Idris monad.
421 | PProvider SyntaxInfo FC Name t t -- ^ Type provider. The first t is the type, the second is the term
422 | PTransform FC Bool t t -- ^ Source-to-source transformation rule. If
423 -- bool is True, lhs and rhs must be convertible
426deriving instance Binary PDecl'
429-- For elaborator state
430type ElabD a = Elab' [PDecl] a
432-- | One clause of a top-level definition. Term arguments to constructors are:
434-- 1. The whole application (missing for PClauseR and PWithR because they're within a "with" clause)
436-- 2. The list of extra 'with' patterns
438-- 3. The right-hand side
440-- 4. The where block (PDecl' t)
442data PClause' t = PClause FC Name t [t] t [PDecl' t] -- ^ A normal top-level definition.
443 | PWith FC Name t [t] t [PDecl' t]
444 | PClauseR FC [t] t [PDecl' t]
445 | PWithR FC [t] t [PDecl' t]
448deriving instance Binary PClause'
452data PData' t = PDatadecl { d_name :: Name, -- ^ The name of the datatype
453 d_tcon :: t, -- ^ Type constructor
454 d_cons :: [(String, Name, t, FC)] -- ^ Constructors
456 -- ^ Data declaration
457 | PLaterdecl { d_name :: Name, d_tcon :: t }
458 -- ^ "Placeholder" for data whose constructors are defined later
461deriving instance Binary PData'
464-- Handy to get a free function for applying PTerm -> PTerm functions
465-- across a program, by deriving Functor
467type PDecl = PDecl' PTerm
468type PData = PData' PTerm
469type PClause = PClause' PTerm
471-- get all the names declared in a decl
473declared :: PDecl -> [Name]
474declared (PFix _ _ _) = []
475declared (PTy _ _ _ _ n t) = [n]
476declared (PPostulate _ _ _ _ n t) = [n]
477declared (PClauses _ _ n _) = [] -- not a declaration
478declared (PCAF _ n _) = [n]
479declared (PData _ _ _ _ (PDatadecl n _ ts)) = n : map fstt ts
480 where fstt (_, a, _, _) = a
481declared (PData _ _ _ _ (PLaterdecl n _)) = [n]
482declared (PParams _ _ ds) = concatMap declared ds
483declared (PNamespace _ ds) = concatMap declared ds
484declared (PRecord _ _ _ n _ _ c _) = [n, c]
485declared (PClass _ _ _ _ n _ ms) = n : concatMap declared ms
486declared (PInstance _ _ _ _ _ _ _ _) = []
487declared (PDSL n _) = [n]
488declared (PSyntax _ _) = []
489declared (PMutual _ ds) = concatMap declared ds
490declared (PDirective _) = []
492-- get the names declared, not counting nested parameter blocks
493tldeclared :: PDecl -> [Name]
494tldeclared (PFix _ _ _) = []
495tldeclared (PTy _ _ _ _ n t) = [n]
496tldeclared (PPostulate _ _ _ _ n t) = [n]
497tldeclared (PClauses _ _ n _) = [] -- not a declaration
498tldeclared (PRecord _ _ _ n _ _ c _) = [n, c]
499tldeclared (PData _ _ _ _ (PDatadecl n _ ts)) = n : map fstt ts
500 where fstt (_, a, _, _) = a
501tldeclared (PParams _ _ ds) = []
502tldeclared (PMutual _ ds) = concatMap tldeclared ds
503tldeclared (PNamespace _ ds) = concatMap tldeclared ds
504tldeclared (PClass _ _ _ _ n _ ms) = concatMap tldeclared ms
505tldeclared (PInstance _ _ _ _ _ _ _ _) = []
508defined :: PDecl -> [Name]
509defined (PFix _ _ _) = []
510defined (PTy _ _ _ _ n t) = []
511defined (PPostulate _ _ _ _ n t) = []
512defined (PClauses _ _ n _) = [n] -- not a declaration
513defined (PCAF _ n _) = [n]
514defined (PData _ _ _ _ (PDatadecl n _ ts)) = n : map fstt ts
515 where fstt (_, a, _, _) = a
516defined (PData _ _ _ _ (PLaterdecl n _)) = []
517defined (PParams _ _ ds) = concatMap defined ds
518defined (PNamespace _ ds) = concatMap defined ds
519defined (PRecord _ _ _ n _ _ c _) = [n, c]
520defined (PClass _ _ _ _ n _ ms) = n : concatMap defined ms
521defined (PInstance _ _ _ _ _ _ _ _) = []
522defined (PDSL n _) = [n]
523defined (PSyntax _ _) = []
524defined (PMutual _ ds) = concatMap defined ds
525defined (PDirective _) = []
528updateN :: [(Name, Name)] -> Name -> Name
529updateN ns n | Just n' <- lookup n ns = n'
532updateNs :: [(Name, Name)] -> PTerm -> PTerm
534updateNs ns t = mapPT updateRef t
535 where updateRef (PRef fc f) = PRef fc (updateN ns f)
538-- updateDNs :: [(Name, Name)] -> PDecl -> PDecl
540-- updateDNs ns (PTy s f n t) | Just n' <- lookup n ns = PTy s f n' t
541-- updateDNs ns (PClauses f n c) | Just n' <- lookup n ns = PClauses f n' (map updateCNs c)
542-- where updateCNs ns (PClause n l ts r ds)
543-- = PClause (updateN ns n) (fmap (updateNs ns) l)
544-- (map (fmap (updateNs ns)) ts)
545-- (fmap (updateNs ns) r)
546-- (map (updateDNs ns) ds)
549-- | High level language terms
550data PTerm = PQuote Raw
552 | PInferRef FC Name -- ^ A name to be defined later
554 | PLam Name PTerm PTerm
555 | PPi Plicity Name PTerm PTerm
556 | PLet Name PTerm PTerm PTerm
557 | PTyped PTerm PTerm -- ^ Term with explicit type
558 | PApp FC PTerm [PArg]
559 | PAppBind FC PTerm [PArg] -- ^ implicitly bound application
560 | PMatchApp FC Name -- ^ Make an application by type matching
561 | PCase FC PTerm [(PTerm, PTerm)]
567 | PRewrite FC PTerm PTerm (Maybe PTerm)
568 | PPair FC PTerm PTerm
569 | PDPair FC PTerm PTerm PTerm
570 | PAlternative Bool [PTerm] -- True if only one may work
571 | PHidden PTerm -- ^ Irrelevant or hidden pattern
573 | PGoal FC PTerm Name PTerm
580 | PProof [PTactic] -- ^ Proof script
581 | PTactics [PTactic] -- ^ As PProof, but no auto solving
582 | PElabError Err -- ^ Error to report on elaboration
583 | PImpossible -- ^ Special case for declaring when an LHS can't typecheck
584 | PCoerced PTerm -- ^ To mark a coerced argument, so as not to coerce twice
585 | PUnifyLog PTerm -- ^ dump a trace of unifications when building term
586 | PNoImplicits PTerm -- ^ never run implicit converions on the term
591deriving instance Binary PTerm
594mapPT :: (PTerm -> PTerm) -> PTerm -> PTerm
595mapPT f t = f (mpt t) where
596 mpt (PLam n t s) = PLam n (mapPT f t) (mapPT f s)
597 mpt (PPi p n t s) = PPi p n (mapPT f t) (mapPT f s)
598 mpt (PLet n ty v s) = PLet n (mapPT f ty) (mapPT f v) (mapPT f s)
599 mpt (PRewrite fc t s g) = PRewrite fc (mapPT f t) (mapPT f s)
601 mpt (PApp fc t as) = PApp fc (mapPT f t) (map (fmap (mapPT f)) as)
602 mpt (PAppBind fc t as) = PAppBind fc (mapPT f t) (map (fmap (mapPT f)) as)
603 mpt (PCase fc c os) = PCase fc (mapPT f c) (map (pmap (mapPT f)) os)
604 mpt (PEq fc l r) = PEq fc (mapPT f l) (mapPT f r)
605 mpt (PTyped l r) = PTyped (mapPT f l) (mapPT f r)
606 mpt (PPair fc l r) = PPair fc (mapPT f l) (mapPT f r)
607 mpt (PDPair fc l t r) = PDPair fc (mapPT f l) (mapPT f t) (mapPT f r)
608 mpt (PAlternative a as) = PAlternative a (map (mapPT f) as)
609 mpt (PHidden t) = PHidden (mapPT f t)
610 mpt (PDoBlock ds) = PDoBlock (map (fmap (mapPT f)) ds)
611 mpt (PProof ts) = PProof (map (fmap (mapPT f)) ts)
612 mpt (PTactics ts) = PTactics (map (fmap (mapPT f)) ts)
613 mpt (PUnifyLog tm) = PUnifyLog (mapPT f tm)
614 mpt (PNoImplicits tm) = PNoImplicits (mapPT f tm)
615 mpt (PGoal fc r n sc) = PGoal fc (mapPT f r) n (mapPT f sc)
619data PTactic' t = Intro [Name] | Intros | Focus Name
620 | Refine Name [Bool] | Rewrite t
623 | LetTac Name t | LetTacTy Name t t
624 | Exact t | Compute | Trivial
625 | ProofSearch (Maybe Name) Name [Name]
628 | ProofState | ProofTerm | Undo
629 | Try (PTactic' t) (PTactic' t)
630 | TSeq (PTactic' t) (PTactic' t)
631 | ApplyTactic t -- see Language.Reflection module
634 | GoalType String (PTactic' t)
636 deriving (Show, Eq, Functor)
638deriving instance Binary PTactic'
641instance Sized a => Sized (PTactic' a) where
642 size (Intro nms) = 1 + size nms
644 size (Focus nm) = 1 + size nm
645 size (Refine nm bs) = 1 + size nm + length bs
646 size (Rewrite t) = 1 + size t
647 size (LetTac nm t) = 1 + size nm + size t
648 size (Exact t) = 1 + size t
656 size (Try l r) = 1 + size l + size r
657 size (TSeq l r) = 1 + size l + size r
658 size (ApplyTactic t) = 1 + size t
659 size (Reflect t) = 1 + size t
660 size (Fill t) = 1 + size t
664type PTactic = PTactic' PTerm
666data PDo' t = DoExp FC t
671 deriving (Eq, Functor)
673deriving instance Binary PDo'
676instance Sized a => Sized (PDo' a) where
677 size (DoExp fc t) = 1 + size fc + size t
678 size (DoBind fc nm t) = 1 + size fc + size nm + size t
679 size (DoBindP fc l r) = 1 + size fc + size l + size r
680 size (DoLet fc nm l r) = 1 + size fc + size nm + size l + size r
681 size (DoLetP fc l r) = 1 + size fc + size l + size r
685-- The priority gives a hint as to elaboration order. Best to elaborate
686-- things early which will help give a more concrete type to other
687-- variables, e.g. a before (interpTy a).
689data PArg' t = PImp { priority :: Int,
690 machine_inf :: Bool, -- true if the machine inferred it
691 lazyarg :: Bool, pname :: Name, getTm :: t,
693 | PExp { priority :: Int,
694 lazyarg :: Bool, getTm :: t,
696 | PConstraint { priority :: Int,
697 lazyarg :: Bool, getTm :: t,
699 | PTacImplicit { priority :: Int,
700 lazyarg :: Bool, pname :: Name,
704 deriving (Show, Eq, Functor)
706instance Sized a => Sized (PArg' a) where
707 size (PImp p _ l nm trm _) = 1 + size nm + size trm
708 size (PExp p l trm _) = 1 + size trm
709 size (PConstraint p l trm _) = 1 + size trm
710 size (PTacImplicit p l nm scr trm _) = 1 + size nm + size scr + size trm
713deriving instance Binary PArg'
716pimp n t mach = PImp 1 mach True n t ""
717pexp t = PExp 1 False t ""
718pconst t = PConstraint 1 False t ""
719ptacimp n s t = PTacImplicit 0 True n s t ""
721type PArg = PArg' PTerm
725data ClassInfo = CI { instanceName :: Name,
726 class_methods :: [(Name, (FnOpts, PTerm))],
727 class_defaults :: [(Name, (Name, PDecl))], -- method name -> default impl
728 class_params :: [Name],
729 class_instances :: [Name] }
732deriving instance Binary ClassInfo
735data OptInfo = Optimise { collapsible :: Bool,
737 forceable :: [Int], -- argument positions
741deriving instance Binary OptInfo
745data TypeInfo = TI { con_names :: [Name],
750deriving instance Binary TypeInfo
753-- Syntactic sugar info
755data DSL' t = DSL { dsl_bind :: t,
760 index_first :: Maybe t,
761 index_next :: Maybe t,
762 dsl_lambda :: Maybe t,
765 deriving (Show, Functor)
767deriving instance Binary DSL'
772data SynContext = PatternSyntax | TermSyntax | AnySyntax
775deriving instance Binary SynContext
778data Syntax = Rule [SSymbol] PTerm SynContext
781deriving instance Binary Syntax
784data SSymbol = Keyword Name
791deriving instance Binary SSymbol
794initDSL = DSL (PRef f (UN ">>="))
795 (PRef f (UN "return"))
803 where f = fileFC "(builtin)"
805data Using = UImplicit Name PTerm
806 | UConstraint Name [Name]
809deriving instance Binary Using
812data SyntaxInfo = Syn { using :: [Using],
813 syn_params :: [(Name, PTerm)],
814 syn_namespace :: [String],
816 decoration :: Name -> Name,
818 implicitAllowed :: Bool,
822deriving instance Binary SyntaxInfo
825defaultSyntax = Syn [] [] [] [] id False False initDSL
827expandNS :: SyntaxInfo -> Name -> Name
828expandNS syn n@(NS _ _) = n
829expandNS syn n = case syn_namespace syn of
834--- Pretty printing declarations and terms
836instance Show PTerm where
837 show tm = showImp Nothing False False tm
839instance Pretty PTerm where
840 pretty = prettyImp False
842instance Show PDecl where
843 show d = showDeclImp False d
845instance Show PClause where
846 show c = showCImp True c
848instance Show PData where
849 show d = showDImp False d
851showDeclImp _ (PFix _ f ops) = show f ++ " " ++ showSep ", " ops
852showDeclImp t (PTy _ _ _ _ n ty) = show n ++ " : " ++ showImp Nothing t False ty
853showDeclImp t (PPostulate _ _ _ _ n ty) = show n ++ " : " ++ showImp Nothing t False ty
854showDeclImp _ (PClauses _ _ n c) = showSep "\n" (map show c)
855showDeclImp _ (PData _ _ _ _ d) = show d
856showDeclImp _ (PParams f ns ps) = "parameters " ++ show ns ++ "\n" ++
857 showSep "\n" (map show ps)
860showCImp :: Bool -> PClause -> String
861showCImp impl (PClause _ n l ws r w)
862 = showImp Nothing impl False l ++ showWs ws ++ " = " ++ showImp Nothing impl False r
863 ++ " where " ++ show w
866 showWs (x : xs) = " | " ++ showImp Nothing impl False x ++ showWs xs
867showCImp impl (PWith _ n l ws r w)
868 = showImp Nothing impl False l ++ showWs ws ++ " with " ++ showImp Nothing impl False r
869 ++ " { " ++ show w ++ " } "
872 showWs (x : xs) = " | " ++ showImp Nothing impl False x ++ showWs xs
875showDImp :: Bool -> PData -> String
876showDImp impl (PDatadecl n ty cons)
877 = "data " ++ show n ++ " : " ++ showImp Nothing impl False ty ++ " where\n\t"
879 (map (\ (_, n, t, _) -> show n ++ " : " ++ showImp Nothing impl False t) cons)
881getImps :: [PArg] -> [(Name, PTerm)]
883getImps (PImp _ _ _ n tm _ : xs) = (n, tm) : getImps xs
884getImps (_ : xs) = getImps xs
886getExps :: [PArg] -> [PTerm]
888getExps (PExp _ _ tm _ : xs) = tm : getExps xs
889getExps (_ : xs) = getExps xs
891getConsts :: [PArg] -> [PTerm]
893getConsts (PConstraint _ _ tm _ : xs) = tm : getConsts xs
894getConsts (_ : xs) = getConsts xs
896getAll :: [PArg] -> [PTerm]
899-- | Pretty-print a high-level Idris term
900prettyImp :: Bool -- ^^ whether to show implicits
901 -> PTerm -- ^^ the term to pretty-print
903prettyImp impl = prettySe 10
905 prettySe p (PQuote r) =
906 if size r > breakingSize then
907 text "![" $$ pretty r <> text "]"
909 text "![" <> pretty r <> text "]"
910 prettySe p (PPatvar fc n) = pretty n
911 prettySe p (PRef fc n) =
917 prettyBasic n@(UN _) = pretty n
918 prettyBasic (MN _ s) = text s
919 prettyBasic (NS n s) = (foldr (<>) empty (intersperse (text ".") (map text $ reverse s))) <> prettyBasic n
920 prettyBasic (SN sn) = text (show sn)
921 prettySe p (PLam n ty sc) =
923 if size sc > breakingSize then
924 text "λ" <> pretty n <+> text "=>" $+$ pretty sc
926 text "λ" <> pretty n <+> text "=>" <+> pretty sc
927 prettySe p (PLet n ty v sc) =
929 if size sc > breakingSize then
930 text "let" <+> pretty n <+> text "=" <+> prettySe 10 v <+> text "in" $+$
931 nest nestingSize (prettySe 10 sc)
933 text "let" <+> pretty n <+> text "=" <+> prettySe 10 v <+> text "in" <+>
935 prettySe p (PPi (Exp l s _ _) n ty sc)
936 | n `elem` allNamesIn sc || impl =
937 let open = if l then text "|" <> lparen else lparen in
939 if size sc > breakingSize then
940 open <> pretty n <+> colon <+> prettySe 10 ty <> rparen <+>
941 st <+> text "->" $+$ prettySe 10 sc
943 open <> pretty n <+> colon <+> prettySe 10 ty <> rparen <+>
944 st <+> text "->" <+> prettySe 10 sc
947 if size sc > breakingSize then
948 prettySe 0 ty <+> st <+> text "->" $+$ prettySe 10 sc
950 prettySe 0 ty <+> st <+> text "->" <+> prettySe 10 sc
954 Static -> text "[static]"
956 prettySe p (PPi (Imp l s _ _) n ty sc)
958 let open = if l then text "|" <> lbrace else lbrace in
960 if size sc > breakingSize then
961 open <> pretty n <+> colon <+> prettySe 10 ty <> rbrace <+>
962 st <+> text "->" <+> prettySe 10 sc
964 open <> pretty n <+> colon <+> prettySe 10 ty <> rbrace <+>
965 st <+> text "->" <+> prettySe 10 sc
966 | otherwise = prettySe 10 sc
970 Static -> text $ "[static]"
972 prettySe p (PPi (Constraint _ _ _) n ty sc) =
974 if size sc > breakingSize then
975 prettySe 10 ty <+> text "=>" <+> prettySe 10 sc
977 prettySe 10 ty <+> text "=>" $+$ prettySe 10 sc
978 prettySe p (PPi (TacImp _ _ s _) n ty sc) =
980 if size sc > breakingSize then
981 lbrace <> text "tacimp" <+> pretty n <+> colon <+> prettySe 10 ty <>
982 rbrace <+> text "->" $+$ prettySe 10 sc
984 lbrace <> text "tacimp" <+> pretty n <+> colon <+> prettySe 10 ty <>
985 rbrace <+> text "->" <+> prettySe 10 sc
986 prettySe p (PApp _ (PRef _ f) [])
987 | not impl = pretty f
988 prettySe p (PAppBind _ (PRef _ f) [])
989 | not impl = text "!" <+> pretty f
990 prettySe p (PApp _ (PRef _ op@(UN (f:_))) args)
991 | length (getExps args) == 2 && (not impl) && (not $ isAlpha f) =
992 let [l, r] = getExps args in
994 if size r > breakingSize then
995 prettySe 1 l <+> pretty op $+$ prettySe 0 r
997 prettySe 1 l <+> pretty op <+> prettySe 0 r
998 prettySe p (PApp _ f as) =
999 let args = getExps as in
1004 -- foldr (<+>) empty $ map prettyArgS as
1006 foldl' fSe empty args
1007 -- foldr (<+>) empty $ map prettyArgSe args
1010 if size r > breakingSize then
1011 l $+$ nest nestingSize (prettyArgS r)
1016 if size r > breakingSize then
1017 l $+$ nest nestingSize (prettyArgSe r)
1020 prettySe p (PCase _ scr opts) =
1021 text "case" <+> prettySe 10 scr <+> text "of" $+$ nest nestingSize prettyBody
1023 prettyBody = foldr ($$) empty $ intersperse (text "|") $ map sc opts
1025 sc (l, r) = prettySe 10 l <+> text "=>" <+> prettySe 10 r
1026 prettySe p (PHidden tm) = text "." <> prettySe 0 tm
1027 prettySe p (PRefl _ _) = text "refl"
1028 prettySe p (PResolveTC _) = text "resolvetc"
1029 prettySe p (PTrue _) = text "()"
1030 prettySe p (PFalse _) = text "_|_"
1031 prettySe p (PEq _ l r) =
1033 if size r > breakingSize then
1034 prettySe 10 l <+> text "=" $$ nest nestingSize (prettySe 10 r)
1036 prettySe 10 l <+> text "=" <+> prettySe 10 r
1037 prettySe p (PRewrite _ l r _) =
1039 if size r > breakingSize then
1040 text "rewrite" <+> prettySe 10 l <+> text "in" $$ nest nestingSize (prettySe 10 r)
1042 text "rewrite" <+> prettySe 10 l <+> text "in" <+> prettySe 10 r
1043 prettySe p (PTyped l r) =
1044 lparen <> prettySe 10 l <+> colon <+> prettySe 10 r <> rparen
1045 prettySe p (PPair _ l r) =
1046 if size r > breakingSize then
1047 lparen <> prettySe 10 l <> text "," $+$
1048 prettySe 10 r <> rparen
1050 lparen <> prettySe 10 l <> text "," <+> prettySe 10 r <> rparen
1051 prettySe p (PDPair _ l t r) =
1052 if size r > breakingSize then
1053 lparen <> prettySe 10 l <+> text "**" $+$
1054 prettySe 10 r <> rparen
1056 lparen <> prettySe 10 l <+> text "**" <+> prettySe 10 r <> rparen
1057 prettySe p (PAlternative a as) =
1058 lparen <> text "|" <> prettyAs <> text "|" <> rparen
1061 foldr (\l -> \r -> l <+> text "," <+> r) empty $ map (prettySe 10) as
1062 prettySe p PType = text "Type"
1063 prettySe p (PConstant c) = pretty c
1064 -- XXX: add pretty for tactics
1065 prettySe p (PProof ts) =
1066 text "proof" <+> lbrace $+$ nest nestingSize (text . show $ ts) $+$ rbrace
1067 prettySe p (PTactics ts) =
1068 text "tactics" <+> lbrace $+$ nest nestingSize (text . show $ ts) $+$ rbrace
1069 prettySe p (PMetavar n) = text "?" <> pretty n
1070 prettySe p (PReturn f) = text "return"
1071 prettySe p PImpossible = text "impossible"
1072 prettySe p Placeholder = text "_"
1073 prettySe p (PDoBlock _) = text "do block pretty not implemented"
1074 prettySe p (PElabError s) = pretty s
1076 prettySe p _ = text "test"
1078 prettyArgS (PImp _ _ _ n tm _) = prettyArgSi (n, tm)
1079 prettyArgS (PExp _ _ tm _) = prettyArgSe tm
1080 prettyArgS (PConstraint _ _ tm _) = prettyArgSc tm
1081 prettyArgS (PTacImplicit _ _ n _ tm _) = prettyArgSti (n, tm)
1083 prettyArgSe arg = prettySe 0 arg
1084 prettyArgSi (n, val) = lbrace <> pretty n <+> text "=" <+> prettySe 10 val <> rbrace
1085 prettyArgSc val = lbrace <> lbrace <> prettySe 10 val <> rbrace <> rbrace
1086 prettyArgSti (n, val) = lbrace <> text "auto" <+> pretty n <+> text "=" <+> prettySe 10 val <> rbrace
1088 bracket outer inner doc
1089 | inner > outer = lparen <> doc <> rparen
1093showName :: Maybe IState -- ^^ the Idris state, for information about names and colours
1094 -> [(Name, Bool)] -- ^^ the bound variables and whether they're implicit
1095 -> Bool -- ^^ whether to show implicits
1096 -> Bool -- ^^ whether to colourise
1097 -> Name -- ^^ the term to show
1099showName ist bnd impl colour n = case ist of
1100 Just i -> if colour then colourise n (idris_colourTheme i) else showbasic n
1101 Nothing -> showbasic n
1102 where name = if impl then show n else showbasic n
1103 showbasic n@(UN _) = show n
1104 showbasic (MN _ s) = s
1105 showbasic (NS n s) = showSep "." (reverse s) ++ "." ++ showbasic n
1106 showbasic (SN s) = show s
1108 colourise n t = let ctxt' = fmap tt_ctxt ist in
1111 Just ctxt | Just impl <- lookup n bnd -> if impl then colouriseImplicit t name
1112 else colouriseBound t name
1113 | isDConName n ctxt -> colouriseData t name
1114 | isFnName n ctxt -> colouriseFun t name
1115 | isTConName n ctxt -> colouriseType t name
1116 -- The assumption is that if a name is not bound and does not exist in the
1117 -- global context, then we're somewhere in which implicit info has been lost
1118 -- (like error messages). Thus, unknown vars are colourised as implicits.
1119 | otherwise -> colouriseImplicit t name
1122showImp :: Maybe IState -- ^^ the Idris state, for information about identifiers and colours
1123 -> Bool -- ^^ whether to show implicits
1124 -> Bool -- ^^ whether to colourise
1125 -> PTerm -- ^^ the term to show
1127showImp ist impl colour tm = se 10 [] tm where
1128 perhapsColourise :: (ColourTheme -> String -> String) -> String -> String
1129 perhapsColourise col str = case ist of
1130 Just i -> if colour then col (idris_colourTheme i) str else str
1133 se :: Int -> [(Name, Bool)] -> PTerm -> String
1134 se p bnd (PQuote r) = "![" ++ show r ++ "]"
1135 se p bnd (PPatvar fc n) = if impl then show n ++ "[p]" else show n
1136 se p bnd (PInferRef fc n) = "!" ++ show n -- ++ "[" ++ show fc ++ "]"
1138 | Just str <- slist p bnd e = str
1139 | Just num <- snat p e = perhapsColourise colouriseData (show num)
1140 se p bnd (PRef fc n) = showName ist bnd impl colour n
1141 se p bnd (PLam n ty sc) = bracket p 2 $ "\\ " ++ perhapsColourise colouriseBound (show n) ++
1142 (if impl then " : " ++ se 10 bnd ty else "") ++ " => "
1143 ++ se 10 ((n, False):bnd) sc
1144 se p bnd (PLet n ty v sc) = bracket p 2 $ "let " ++ perhapsColourise colouriseBound (show n) ++
1145 " = " ++ se 10 bnd v ++
1146 " in " ++ se 10 ((n, False):bnd) sc
1147 se p bnd (PPi (Exp l s _ param) n ty sc)
1148 | n `elem` allNamesIn sc || impl
1150 (if l then "|(" else "(") ++
1151 perhapsColourise colouriseBound (show n) ++ " : " ++ se 10 bnd ty ++
1153 (if (impl && param) then "P" else "") ++
1155 "-> " ++ se 10 ((n, False):bnd) sc
1156 | otherwise = bracket p 2 $ se 0 bnd ty ++ " " ++ st ++ "-> " ++ se 10 bnd sc
1157 where st = case s of
1158 Static -> "[static] "
1160 se p bnd (PPi (Imp l s _ _) n ty sc)
1161 | impl = bracket p 2 $ (if l then "|{" else "{") ++
1162 perhapsColourise colouriseBound (show n) ++ " : " ++ se 10 bnd ty ++
1163 "} " ++ st ++ "-> " ++ se 10 ((n, True):bnd) sc
1164 | otherwise = se 10 ((n, True):bnd) sc
1165 where st = case s of
1166 Static -> "[static] "
1168 se p bnd (PPi (Constraint _ _ _) n ty sc)
1169 = bracket p 2 $ se 10 bnd ty ++ " => " ++ se 10 bnd sc
1170 se p bnd (PPi (TacImp _ _ s _) n ty sc)
1172 "{tacimp " ++ (perhapsColourise colouriseBound (show n)) ++ " : " ++ se 10 bnd ty ++ "} -> " ++
1173 se 10 ((n, False):bnd) sc
1174 se p bnd (PMatchApp _ f) = "match " ++ show f
1175 se p bnd (PApp _ hd@(PRef _ f) [])
1176 | not impl = se p bnd hd
1177 se p bnd (PAppBind _ hd@(PRef _ f) [])
1178 | not impl = "!" ++ se p bnd hd
1179 se p bnd (PApp _ op@(PRef _ (UN (f:_))) args)
1180 | length (getExps args) == 2 && not impl && not (isAlpha f)
1181 = let [l, r] = getExps args in
1182 bracket p 1 $ se 1 bnd l ++ " " ++ se p bnd op ++ " " ++ se 0 bnd r
1183 se p bnd (PApp _ f as)
1184 = -- let args = getExps as in
1185 bracket p 1 $ se 1 bnd f ++
1186 if impl then concatMap (sArg bnd) as
1187 else concatMap (suiArg impl bnd) as
1188 se p bnd (PAppBind _ f as)
1189 = let args = getExps as in
1190 "!" ++ (bracket p 1 $ se 1 bnd f ++ if impl then concatMap (sArg bnd) as
1191 else concatMap (seArg bnd) args)
1192 se p bnd (PCase _ scr opts) = "case " ++ se 10 bnd scr ++ " of " ++ showSep " | " (map sc opts)
1193 where sc (l, r) = se 10 bnd l ++ " => " ++ se 10 bnd r
1194 se p bnd (PHidden tm) = "." ++ se 0 bnd tm
1195 se p bnd (PRefl _ t)
1196 | not impl = perhapsColourise colouriseData "refl"
1197 | otherwise = perhapsColourise colouriseData $ "refl {" ++ se 10 bnd t ++ "}"
1198 se p bnd (PResolveTC _) = "resolvetc"
1199 se p bnd (PTrue _) = perhapsColourise colouriseType "()"
1200 se p bnd (PFalse _) = perhapsColourise colouriseType "_|_"
1201 se p bnd (PEq _ l r) = bracket p 2 $ se 10 bnd l ++ perhapsColourise colouriseType " = " ++ se 10 bnd r
1202 se p bnd (PRewrite _ l r _) = bracket p 2 $ "rewrite " ++ se 10 bnd l ++ " in " ++ se 10 bnd r
1203 se p bnd (PTyped l r) = "(" ++ se 10 bnd l ++ " : " ++ se 10 bnd r ++ ")"
1204 se p bnd (PPair _ l r) = "(" ++ se 10 bnd l ++ ", " ++ se 10 bnd r ++ ")"
1205 se p bnd (PDPair _ l t r) = "(" ++ se 10 bnd l ++ " ** " ++ se 10 bnd r ++ ")"
1206 se p bnd (PAlternative a as) = "(|" ++ showSep " , " (map (se 10 bnd) as) ++ "|)"
1207 se p bnd PType = perhapsColourise colouriseType "Type"
1208 se p bnd (PConstant c) = perhapsColourise (cfun c) (show c)
1209 where cfun (AType _) = colouriseType
1210 cfun StrType = colouriseType
1211 cfun PtrType = colouriseType
1212 cfun VoidType = colouriseType
1213 cfun _ = colouriseData
1214 se p bnd (PProof ts) = "proof { " ++ show ts ++ "}"
1215 se p bnd (PTactics ts) = "tactics { " ++ show ts ++ "}"
1216 se p bnd (PMetavar n) = "?" ++ show n
1217 se p bnd (PReturn f) = "return"
1218 se p bnd PImpossible = "impossible"
1219 se p bnd Placeholder = "_"
1220 se p bnd (PDoBlock _) = "do block show not implemented"
1221 se p bnd (PElabError s) = show s
1222 se p bnd (PCoerced t) = se p bnd t
1223 se p bnd (PUnifyLog t) = "%unifyLog " ++ se p bnd t
1224 se p bnd (PNoImplicits t) = "%noimplicit " ++ se p bnd t
1225-- se p bnd x = "Not implemented"
1227 slist' p bnd (PApp _ (PRef _ nil) _)
1228 | not impl && nsroot nil == UN "Nil" = Just []
1229 slist' p bnd (PApp _ (PRef _ cons) args)
1230 | nsroot cons == UN "::",
1231 (PExp {getTm=tl}):(PExp {getTm=hd}):imps <- reverse args,
1233 Just tl' <- slist' p bnd tl
1236 isImp (PImp {}) = True
1238 slist' _ _ _ = Nothing
1240 slist p bnd e | Just es <- slist' p bnd e = Just $
1241 case es of [] -> "[]"
1242 [x] -> "[" ++ se p bnd x ++ "]"
1243 xs -> "[" ++ intercalate "," (map (se p bnd ) xs) ++ "]"
1244 slist _ _ _ = Nothing
1246 -- since Prelude is always imported, S & Z are unqualified iff they're the
1249 | show o == (natns++"Z") || show o == "Z" = Just 0
1250 snat p (PApp _ s [PExp {getTm=n}])
1251 | show s == (natns++"S") || show s == "S",
1256 natns = "Prelude.Nat."
1258 sArg bnd (PImp _ _ _ n tm _) = siArg bnd (n, tm)
1259 sArg bnd (PExp _ _ tm _) = seArg bnd tm
1260 sArg bnd (PConstraint _ _ tm _) = scArg bnd tm
1261 sArg bnd (PTacImplicit _ _ n _ tm _) = stiArg bnd (n, tm)
1263 -- show argument, implicits given by the user also shown
1264 suiArg impl bnd (PImp _ mi _ n tm _)
1265 | impl || not mi = siArg bnd (n, tm)
1266 suiArg impl bnd (PExp _ _ tm _) = seArg bnd tm
1267 suiArg impl bnd _ = ""
1269 seArg bnd arg = " " ++ se 0 bnd arg
1270 siArg bnd (n, val) =
1272 val' = se 10 bnd val in
1274 then " {" ++ n' ++ "}"
1275 else " {" ++ n' ++ " = " ++ val' ++ "}"
1276 scArg bnd val = " {{" ++ se 10 bnd val ++ "}}"
1277 stiArg bnd (n, val) = " {auto " ++ show n ++ " = " ++ se 10 bnd val ++ "}"
1279 bracket outer inner str | inner > outer = "(" ++ str ++ ")"
1283instance Sized PTerm where
1284 size (PQuote rawTerm) = size rawTerm
1285 size (PRef fc name) = size name
1286 size (PLam name ty bdy) = 1 + size ty + size bdy
1287 size (PPi plicity name ty bdy) = 1 + size ty + size bdy
1288 size (PLet name ty def bdy) = 1 + size ty + size def + size bdy
1289 size (PTyped trm ty) = 1 + size trm + size ty
1290 size (PApp fc name args) = 1 + size args
1291 size (PAppBind fc name args) = 1 + size args
1292 size (PCase fc trm bdy) = 1 + size trm + size bdy
1294 size (PFalse fc) = 1
1295 size (PRefl fc _) = 1
1296 size (PResolveTC fc) = 1
1297 size (PEq fc left right) = 1 + size left + size right
1298 size (PRewrite fc left right _) = 1 + size left + size right
1299 size (PPair fc left right) = 1 + size left + size right
1300 size (PDPair fs left ty right) = 1 + size left + size ty + size right
1301 size (PAlternative a alts) = 1 + size alts
1302 size (PHidden hidden) = size hidden
1303 size (PUnifyLog tm) = size tm
1304 size (PNoImplicits tm) = size tm
1306 size (PConstant const) = 1 + size const
1307 size Placeholder = 1
1308 size (PDoBlock dos) = 1 + size dos
1309 size (PIdiom fc term) = 1 + size term
1310 size (PReturn fc) = 1
1311 size (PMetavar name) = 1
1312 size (PProof tactics) = size tactics
1313 size (PElabError err) = size err
1314 size PImpossible = 1
1316getPArity :: PTerm -> Int
1317getPArity (PPi _ _ _ sc) = 1 + getPArity sc
1320-- Return all names, free or globally bound, in the given term.
1322allNamesIn :: PTerm -> [Name]
1323allNamesIn tm = nub $ ni [] tm
1326 | not (n `elem` env) = [n]
1327 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1328 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1329 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1330 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1331 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
1332 ni env (PHidden tm) = ni env tm
1333 ni env (PEq _ l r) = ni env l ++ ni env r
1334 ni env (PRewrite _ l r _) = ni env l ++ ni env r
1335 ni env (PTyped l r) = ni env l ++ ni env r
1336 ni env (PPair _ l r) = ni env l ++ ni env r
1337 ni env (PDPair _ (PRef _ n) t r) = ni env t ++ ni (n:env) r
1338 ni env (PDPair _ l t r) = ni env l ++ ni env t ++ ni env r
1339 ni env (PAlternative a ls) = concatMap (ni env) ls
1340 ni env (PUnifyLog tm) = ni env tm
1341 ni env (PNoImplicits tm) = ni env tm
1344-- Return names which are free in the given term.
1346namesIn :: [(Name, PTerm)] -> IState -> PTerm -> [Name]
1347namesIn uvars ist tm = nub $ ni [] tm
1350 | not (n `elem` env)
1351 = case lookupTy n (tt_ctxt ist) of
1353 _ -> if n `elem` (map fst uvars) then [n] else []
1354 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1355 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1356 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1357 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1358 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
1359 ni env (PEq _ l r) = ni env l ++ ni env r
1360 ni env (PRewrite _ l r _) = ni env l ++ ni env r
1361 ni env (PTyped l r) = ni env l ++ ni env r
1362 ni env (PPair _ l r) = ni env l ++ ni env r
1363 ni env (PDPair _ (PRef _ n) t r) = ni env t ++ ni (n:env) r
1364 ni env (PDPair _ l t r) = ni env l ++ ni env t ++ ni env r
1365 ni env (PAlternative a as) = concatMap (ni env) as
1366 ni env (PHidden tm) = ni env tm
1367 ni env (PUnifyLog tm) = ni env tm
1368 ni env (PNoImplicits tm) = ni env tm
1371-- Return which of the given names are used in the given term.
1373usedNamesIn :: [Name] -> IState -> PTerm -> [Name]
1374usedNamesIn vars ist tm = nub $ ni [] tm
1377 | n `elem` vars && not (n `elem` env)
1378 = case lookupTy n (tt_ctxt ist) of
1381 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1382 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1383 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1384 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1385 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
1386 ni env (PEq _ l r) = ni env l ++ ni env r
1387 ni env (PRewrite _ l r _) = ni env l ++ ni env r
1388 ni env (PTyped l r) = ni env l ++ ni env r
1389 ni env (PPair _ l r) = ni env l ++ ni env r
1390 ni env (PDPair _ (PRef _ n) t r) = ni env t ++ ni (n:env) r
1391 ni env (PDPair _ l t r) = ni env l ++ ni env t ++ ni env r
1392 ni env (PAlternative a as) = concatMap (ni env) as
1393 ni env (PHidden tm) = ni env tm
1394 ni env (PUnifyLog tm) = ni env tm
1395 ni env (PNoImplicits tm) = ni env tm
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list