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], -- ^ 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,
134data SizeChange = Smaller | Same | Bigger | Unknown
137deriving instance Binary SizeChange
140type SCGEntry = (Name, [Maybe (Int, SizeChange)])
142data CGInfo = CGInfo { argsdef :: [Name],
143 calls :: [(Name, [[Name]])],
149deriving instance Binary CGInfo
152primDefs = [UN "unsafePerformPrimIO",
153 UN "mkLazyForeignPrim",
157-- information that needs writing for the current module's .ibc file
158data IBCWrite = IBCFix FixDecl
162 | IBCInstance Bool Name Name
169 | IBCObj Codegen FilePath
170 | IBCLib Codegen String
171 | IBCCGFlag Codegen String
173 | IBCHeader Codegen String
174 | IBCAccess Name Accessibility
175 | IBCTotal Name Totality
176 | IBCFlags Name [FnOpt]
177 | IBCTrans (Term, Term)
181 | IBCDef Name -- i.e. main context
182 | IBCLineApp FilePath Int PTerm
185idrisInit = IState initContext [] [] emptyContext emptyContext emptyContext
186 emptyContext emptyContext emptyContext emptyContext
187 emptyContext emptyContext emptyContext emptyContext
188 [] "" defaultOpts 6 [] [] [] [] [] [] [] [] [] [] [] []
189 [] Nothing Nothing [] [] [] Hidden False [] Nothing [] [] RawOutput
190 True defaultTheme stdout
192-- | The monad for the main REPL - reading and processing files and updating
193-- global state (hence the IO inner monad).
194--type Idris = WriterT [Either String (IO ())] (State IState a))
195type Idris = StateT IState (ErrorT Err IO)
197-- Commands in the REPL
216 | ChangeDirectory FilePath
219 | Compile Codegen String
224 | AddProof (Maybe Name)
237 | DynamicLink FilePath
242 | CaseSplit Name PTerm
243 | CaseSplitAt Bool Int Name
244 | AddClauseFrom Bool Int Name
245 | MakeWith Bool Int Name
249 | SetColour ColourType IdrisColour
253data Opt = Filename String
287 | OutputTy OutputType
288 | Extension LanguageExt
289 | InterpretScript String
290 | TargetTriple String
296-- Parsed declarations
298data Fixity = Infixl { prec :: Int }
299 | Infixr { prec :: Int }
300 | InfixN { prec :: Int }
301 | PrefixN { prec :: Int }
304deriving instance Binary Fixity
307instance Show Fixity where
308 show (Infixl i) = "infixl " ++ show i
309 show (Infixr i) = "infixr " ++ show i
310 show (InfixN i) = "infix " ++ show i
311 show (PrefixN i) = "prefix " ++ show i
313data FixDecl = Fix Fixity String
316instance Show FixDecl where
317 show (Fix f s) = show f ++ " " ++ s
320deriving instance Binary FixDecl
323instance Ord FixDecl where
324 compare (Fix x _) (Fix y _) = compare (prec x) (prec y)
327data Static = Static | Dynamic
330deriving instance Binary Static
333-- Mark bindings with their explicitness, and laziness
334data Plicity = Imp { plazy :: Bool,
338 | Exp { plazy :: Bool,
342 | Constraint { plazy :: Bool,
345 | TacImp { plazy :: Bool,
352deriving instance Binary Plicity
355impl = Imp False Dynamic "" False
356expl = Exp False Dynamic "" False
357expl_param = Exp False Dynamic "" True
358constraint = Constraint False Dynamic ""
359tacimpl t = TacImp False Dynamic t ""
361data FnOpt = Inlinable -- always evaluate when simplifying
362 | TotalFn | PartialFn
363 | Coinductive | AssertTotal
364 | Dictionary -- type class dictionary, eval only when
365 -- a function argument, and further evaluation resutls
366 | Implicit -- implicit coercion
367 | CExport String -- export, with a C name
368 | Reflection -- a reflecting function, compile-time only
369 | Specialise [(Name, Maybe Int)] -- specialise it, freeze these names
372deriving instance Binary FnOpt
377inlinable :: FnOpts -> Bool
378inlinable = elem Inlinable
380dictionary :: FnOpts -> Bool
381dictionary = elem Dictionary
383-- | Top-level declarations such as compiler directives, definitions,
384-- datatypes and typeclasses.
386 = PFix FC Fixity [String] -- ^ Fixity declaration
387 | PTy String SyntaxInfo FC FnOpts Name t -- ^ Type declaration
388 | PPostulate String SyntaxInfo FC FnOpts Name t -- ^ Postulate
389 | PClauses FC FnOpts Name [PClause' t] -- ^ Pattern clause
390 | PCAF FC Name t -- ^ Top level constant
391 | PData String SyntaxInfo FC Bool (PData' t) -- ^ Data declaration. The Bool argument is True for codata.
392 | PParams FC [(Name, t)] [PDecl' t] -- ^ Params block
393 | PNamespace String [PDecl' t] -- ^ New namespace
394 | PRecord String SyntaxInfo FC Name t String Name t -- ^ Record declaration
395 | PClass String SyntaxInfo FC
398 [(Name, t)] -- parameters
399 [PDecl' t] -- declarations
400 -- ^ Type class: arguments are documentation, syntax info, source location, constraints,
401 -- class name, parameters, method declarations
402 | PInstance SyntaxInfo FC [t] -- constraints
405 t -- full instance type
406 (Maybe Name) -- explicit name
408 -- ^ Instance declaration: arguments are syntax info, source location, constraints,
409 -- class name, parameters, full instance type, optional explicit name, and definitions
410 | PDSL Name (DSL' t) -- ^ DSL declaration
411 | PSyntax FC Syntax -- ^ Syntax definition
412 | PMutual FC [PDecl' t] -- ^ Mutual block
413 | PDirective (Idris ()) -- ^ Compiler directive. The parser inserts the corresponding action in the Idris monad.
414 | PProvider SyntaxInfo FC Name t t -- ^ Type provider. The first t is the type, the second is the term
415 | PTransform FC Bool t t -- ^ Source-to-source transformation rule. If
416 -- bool is True, lhs and rhs must be convertible
419deriving instance Binary PDecl'
422-- | One clause of a top-level definition. Term arguments to constructors are:
424-- 1. The whole application (missing for PClauseR and PWithR because they're within a "with" clause)
426-- 2. The list of extra 'with' patterns
428-- 3. The right-hand side
430-- 4. The where block (PDecl' t)
432data PClause' t = PClause FC Name t [t] t [PDecl' t] -- ^ A normal top-level definition.
433 | PWith FC Name t [t] t [PDecl' t]
434 | PClauseR FC [t] t [PDecl' t]
435 | PWithR FC [t] t [PDecl' t]
438deriving instance Binary PClause'
442data PData' t = PDatadecl { d_name :: Name, -- ^ The name of the datatype
443 d_tcon :: t, -- ^ Type constructor
444 d_cons :: [(String, Name, t, FC)] -- ^ Constructors
446 -- ^ Data declaration
447 | PLaterdecl { d_name :: Name, d_tcon :: t }
448 -- ^ "Placeholder" for data whose constructors are defined later
451deriving instance Binary PData'
454-- Handy to get a free function for applying PTerm -> PTerm functions
455-- across a program, by deriving Functor
457type PDecl = PDecl' PTerm
458type PData = PData' PTerm
459type PClause = PClause' PTerm
461-- get all the names declared in a decl
463declared :: PDecl -> [Name]
464declared (PFix _ _ _) = []
465declared (PTy _ _ _ _ n t) = [n]
466declared (PPostulate _ _ _ _ n t) = [n]
467declared (PClauses _ _ n _) = [] -- not a declaration
468declared (PCAF _ n _) = [n]
469declared (PData _ _ _ _ (PDatadecl n _ ts)) = n : map fstt ts
470 where fstt (_, a, _, _) = a
471declared (PData _ _ _ _ (PLaterdecl n _)) = [n]
472declared (PParams _ _ ds) = concatMap declared ds
473declared (PNamespace _ ds) = concatMap declared ds
474declared (PRecord _ _ _ n _ _ c _) = [n, c]
475declared (PClass _ _ _ _ n _ ms) = n : concatMap declared ms
476declared (PInstance _ _ _ _ _ _ _ _) = []
477declared (PDSL n _) = [n]
478declared (PSyntax _ _) = []
479declared (PMutual _ ds) = concatMap declared ds
480declared (PDirective _) = []
482-- get the names declared, not counting nested parameter blocks
483tldeclared :: PDecl -> [Name]
484tldeclared (PFix _ _ _) = []
485tldeclared (PTy _ _ _ _ n t) = [n]
486tldeclared (PPostulate _ _ _ _ n t) = [n]
487tldeclared (PClauses _ _ n _) = [] -- not a declaration
488tldeclared (PRecord _ _ _ n _ _ c _) = [n, c]
489tldeclared (PData _ _ _ _ (PDatadecl n _ ts)) = n : map fstt ts
490 where fstt (_, a, _, _) = a
491tldeclared (PParams _ _ ds) = []
492tldeclared (PMutual _ ds) = concatMap tldeclared ds
493tldeclared (PNamespace _ ds) = concatMap tldeclared ds
494tldeclared (PClass _ _ _ _ n _ ms) = concatMap tldeclared ms
495tldeclared (PInstance _ _ _ _ _ _ _ _) = []
498defined :: PDecl -> [Name]
499defined (PFix _ _ _) = []
500defined (PTy _ _ _ _ n t) = []
501defined (PPostulate _ _ _ _ n t) = []
502defined (PClauses _ _ n _) = [n] -- not a declaration
503defined (PCAF _ n _) = [n]
504defined (PData _ _ _ _ (PDatadecl n _ ts)) = n : map fstt ts
505 where fstt (_, a, _, _) = a
506defined (PData _ _ _ _ (PLaterdecl n _)) = []
507defined (PParams _ _ ds) = concatMap defined ds
508defined (PNamespace _ ds) = concatMap defined ds
509defined (PRecord _ _ _ n _ _ c _) = [n, c]
510defined (PClass _ _ _ _ n _ ms) = n : concatMap defined ms
511defined (PInstance _ _ _ _ _ _ _ _) = []
512defined (PDSL n _) = [n]
513defined (PSyntax _ _) = []
514defined (PMutual _ ds) = concatMap defined ds
515defined (PDirective _) = []
518updateN :: [(Name, Name)] -> Name -> Name
519updateN ns n | Just n' <- lookup n ns = n'
522updateNs :: [(Name, Name)] -> PTerm -> PTerm
524updateNs ns t = mapPT updateRef t
525 where updateRef (PRef fc f) = PRef fc (updateN ns f)
528-- updateDNs :: [(Name, Name)] -> PDecl -> PDecl
530-- updateDNs ns (PTy s f n t) | Just n' <- lookup n ns = PTy s f n' t
531-- updateDNs ns (PClauses f n c) | Just n' <- lookup n ns = PClauses f n' (map updateCNs c)
532-- where updateCNs ns (PClause n l ts r ds)
533-- = PClause (updateN ns n) (fmap (updateNs ns) l)
534-- (map (fmap (updateNs ns)) ts)
535-- (fmap (updateNs ns) r)
536-- (map (updateDNs ns) ds)
539-- | High level language terms
540data PTerm = PQuote Raw
542 | PInferRef FC Name -- ^ A name to be defined later
544 | PLam Name PTerm PTerm
545 | PPi Plicity Name PTerm PTerm
546 | PLet Name PTerm PTerm PTerm
547 | PTyped PTerm PTerm -- ^ Term with explicit type
548 | PApp FC PTerm [PArg]
549 | PAppBind FC PTerm [PArg] -- ^ implicitly bound application
550 | PMatchApp FC Name -- ^ Make an application by type matching
551 | PCase FC PTerm [(PTerm, PTerm)]
557 | PRewrite FC PTerm PTerm (Maybe PTerm)
558 | PPair FC PTerm PTerm
559 | PDPair FC PTerm PTerm PTerm
560 | PAlternative Bool [PTerm] -- True if only one may work
561 | PHidden PTerm -- ^ Irrelevant or hidden pattern
563 | PGoal FC PTerm Name PTerm
570 | PProof [PTactic] -- ^ Proof script
571 | PTactics [PTactic] -- ^ As PProof, but no auto solving
572 | PElabError Err -- ^ Error to report on elaboration
573 | PImpossible -- ^ Special case for declaring when an LHS can't typecheck
574 | PCoerced PTerm -- ^ To mark a coerced argument, so as not to coerce twice
575 | PUnifyLog PTerm -- ^ dump a trace of unifications when building term
576 | PNoImplicits PTerm -- ^ never run implicit converions on the term
581deriving instance Binary PTerm
584mapPT :: (PTerm -> PTerm) -> PTerm -> PTerm
585mapPT f t = f (mpt t) where
586 mpt (PLam n t s) = PLam n (mapPT f t) (mapPT f s)
587 mpt (PPi p n t s) = PPi p n (mapPT f t) (mapPT f s)
588 mpt (PLet n ty v s) = PLet n (mapPT f ty) (mapPT f v) (mapPT f s)
589 mpt (PRewrite fc t s g) = PRewrite fc (mapPT f t) (mapPT f s)
591 mpt (PApp fc t as) = PApp fc (mapPT f t) (map (fmap (mapPT f)) as)
592 mpt (PAppBind fc t as) = PAppBind fc (mapPT f t) (map (fmap (mapPT f)) as)
593 mpt (PCase fc c os) = PCase fc (mapPT f c) (map (pmap (mapPT f)) os)
594 mpt (PEq fc l r) = PEq fc (mapPT f l) (mapPT f r)
595 mpt (PTyped l r) = PTyped (mapPT f l) (mapPT f r)
596 mpt (PPair fc l r) = PPair fc (mapPT f l) (mapPT f r)
597 mpt (PDPair fc l t r) = PDPair fc (mapPT f l) (mapPT f t) (mapPT f r)
598 mpt (PAlternative a as) = PAlternative a (map (mapPT f) as)
599 mpt (PHidden t) = PHidden (mapPT f t)
600 mpt (PDoBlock ds) = PDoBlock (map (fmap (mapPT f)) ds)
601 mpt (PProof ts) = PProof (map (fmap (mapPT f)) ts)
602 mpt (PTactics ts) = PTactics (map (fmap (mapPT f)) ts)
603 mpt (PUnifyLog tm) = PUnifyLog (mapPT f tm)
604 mpt (PNoImplicits tm) = PNoImplicits (mapPT f tm)
605 mpt (PGoal fc r n sc) = PGoal fc (mapPT f r) n (mapPT f sc)
609data PTactic' t = Intro [Name] | Intros | Focus Name
610 | Refine Name [Bool] | Rewrite t
613 | LetTac Name t | LetTacTy Name t t
614 | Exact t | Compute | Trivial
617 | ProofState | ProofTerm | Undo
618 | Try (PTactic' t) (PTactic' t)
619 | TSeq (PTactic' t) (PTactic' t)
620 | ApplyTactic t -- see Language.Reflection module
623 | GoalType String (PTactic' t)
625 deriving (Show, Eq, Functor)
627deriving instance Binary PTactic'
630instance Sized a => Sized (PTactic' a) where
631 size (Intro nms) = 1 + size nms
633 size (Focus nm) = 1 + size nm
634 size (Refine nm bs) = 1 + size nm + length bs
635 size (Rewrite t) = 1 + size t
636 size (LetTac nm t) = 1 + size nm + size t
637 size (Exact t) = 1 + size t
645 size (Try l r) = 1 + size l + size r
646 size (TSeq l r) = 1 + size l + size r
647 size (ApplyTactic t) = 1 + size t
648 size (Reflect t) = 1 + size t
649 size (Fill t) = 1 + size t
653type PTactic = PTactic' PTerm
655data PDo' t = DoExp FC t
660 deriving (Eq, Functor)
662deriving instance Binary PDo'
665instance Sized a => Sized (PDo' a) where
666 size (DoExp fc t) = 1 + size fc + size t
667 size (DoBind fc nm t) = 1 + size fc + size nm + size t
668 size (DoBindP fc l r) = 1 + size fc + size l + size r
669 size (DoLet fc nm l r) = 1 + size fc + size nm + size l + size r
670 size (DoLetP fc l r) = 1 + size fc + size l + size r
674-- The priority gives a hint as to elaboration order. Best to elaborate
675-- things early which will help give a more concrete type to other
676-- variables, e.g. a before (interpTy a).
678data PArg' t = PImp { priority :: Int,
679 machine_inf :: Bool, -- true if the machine inferred it
680 lazyarg :: Bool, pname :: Name, getTm :: t,
682 | PExp { priority :: Int,
683 lazyarg :: Bool, getTm :: t,
685 | PConstraint { priority :: Int,
686 lazyarg :: Bool, getTm :: t,
688 | PTacImplicit { priority :: Int,
689 lazyarg :: Bool, pname :: Name,
693 deriving (Show, Eq, Functor)
695instance Sized a => Sized (PArg' a) where
696 size (PImp p _ l nm trm _) = 1 + size nm + size trm
697 size (PExp p l trm _) = 1 + size trm
698 size (PConstraint p l trm _) = 1 + size trm
699 size (PTacImplicit p l nm scr trm _) = 1 + size nm + size scr + size trm
702deriving instance Binary PArg'
705pimp n t mach = PImp 1 mach True n t ""
706pexp t = PExp 1 False t ""
707pconst t = PConstraint 1 False t ""
708ptacimp n s t = PTacImplicit 0 True n s t ""
710type PArg = PArg' PTerm
714data ClassInfo = CI { instanceName :: Name,
715 class_methods :: [(Name, (FnOpts, PTerm))],
716 class_defaults :: [(Name, (Name, PDecl))], -- method name -> default impl
717 class_params :: [Name],
718 class_instances :: [Name] }
721deriving instance Binary ClassInfo
724data OptInfo = Optimise { collapsible :: Bool,
726 forceable :: [Int], -- argument positions
730deriving instance Binary OptInfo
734data TypeInfo = TI { con_names :: [Name],
739deriving instance Binary TypeInfo
742-- Syntactic sugar info
744data DSL' t = DSL { dsl_bind :: t,
749 index_first :: Maybe t,
750 index_next :: Maybe t,
751 dsl_lambda :: Maybe t,
754 deriving (Show, Functor)
756deriving instance Binary DSL'
761data SynContext = PatternSyntax | TermSyntax | AnySyntax
764deriving instance Binary SynContext
767data Syntax = Rule [SSymbol] PTerm SynContext
770deriving instance Binary Syntax
773data SSymbol = Keyword Name
780deriving instance Binary SSymbol
783initDSL = DSL (PRef f (UN ">>="))
784 (PRef f (UN "return"))
792 where f = fileFC "(builtin)"
794data Using = UImplicit Name PTerm
795 | UConstraint Name [Name]
798deriving instance Binary Using
801data SyntaxInfo = Syn { using :: [Using],
802 syn_params :: [(Name, PTerm)],
803 syn_namespace :: [String],
805 decoration :: Name -> Name,
807 implicitAllowed :: Bool,
811deriving instance Binary SyntaxInfo
814defaultSyntax = Syn [] [] [] [] id False False initDSL
816expandNS :: SyntaxInfo -> Name -> Name
817expandNS syn n@(NS _ _) = n
818expandNS syn n = case syn_namespace syn of
823--- Pretty printing declarations and terms
825instance Show PTerm where
826 show tm = showImp Nothing False False tm
828instance Pretty PTerm where
829 pretty = prettyImp False
831instance Show PDecl where
832 show d = showDeclImp False d
834instance Show PClause where
835 show c = showCImp True c
837instance Show PData where
838 show d = showDImp False d
840showDeclImp _ (PFix _ f ops) = show f ++ " " ++ showSep ", " ops
841showDeclImp t (PTy _ _ _ _ n ty) = show n ++ " : " ++ showImp Nothing t False ty
842showDeclImp t (PPostulate _ _ _ _ n ty) = show n ++ " : " ++ showImp Nothing t False ty
843showDeclImp _ (PClauses _ _ n c) = showSep "\n" (map show c)
844showDeclImp _ (PData _ _ _ _ d) = show d
845showDeclImp _ (PParams f ns ps) = "parameters " ++ show ns ++ "\n" ++
846 showSep "\n" (map show ps)
849showCImp :: Bool -> PClause -> String
850showCImp impl (PClause _ n l ws r w)
851 = showImp Nothing impl False l ++ showWs ws ++ " = " ++ showImp Nothing impl False r
852 ++ " where " ++ show w
855 showWs (x : xs) = " | " ++ showImp Nothing impl False x ++ showWs xs
856showCImp impl (PWith _ n l ws r w)
857 = showImp Nothing impl False l ++ showWs ws ++ " with " ++ showImp Nothing impl False r
858 ++ " { " ++ show w ++ " } "
861 showWs (x : xs) = " | " ++ showImp Nothing impl False x ++ showWs xs
864showDImp :: Bool -> PData -> String
865showDImp impl (PDatadecl n ty cons)
866 = "data " ++ show n ++ " : " ++ showImp Nothing impl False ty ++ " where\n\t"
868 (map (\ (_, n, t, _) -> show n ++ " : " ++ showImp Nothing impl False t) cons)
870getImps :: [PArg] -> [(Name, PTerm)]
872getImps (PImp _ _ _ n tm _ : xs) = (n, tm) : getImps xs
873getImps (_ : xs) = getImps xs
875getExps :: [PArg] -> [PTerm]
877getExps (PExp _ _ tm _ : xs) = tm : getExps xs
878getExps (_ : xs) = getExps xs
880getConsts :: [PArg] -> [PTerm]
882getConsts (PConstraint _ _ tm _ : xs) = tm : getConsts xs
883getConsts (_ : xs) = getConsts xs
885getAll :: [PArg] -> [PTerm]
888-- | Pretty-print a high-level Idris term
889prettyImp :: Bool -- ^^ whether to show implicits
890 -> PTerm -- ^^ the term to pretty-print
892prettyImp impl = prettySe 10
894 prettySe p (PQuote r) =
895 if size r > breakingSize then
896 text "![" $$ pretty r <> text "]"
898 text "![" <> pretty r <> text "]"
899 prettySe p (PPatvar fc n) = pretty n
900 prettySe p (PRef fc n) =
906 prettyBasic n@(UN _) = pretty n
907 prettyBasic (MN _ s) = text s
908 prettyBasic (NS n s) = (foldr (<>) empty (intersperse (text ".") (map text $ reverse s))) <> prettyBasic n
909 prettyBasic (SN sn) = text (show sn)
910 prettySe p (PLam n ty sc) =
912 if size sc > breakingSize then
913 text "λ" <> pretty n <+> text "=>" $+$ pretty sc
915 text "λ" <> pretty n <+> text "=>" <+> pretty sc
916 prettySe p (PLet n ty v sc) =
918 if size sc > breakingSize then
919 text "let" <+> pretty n <+> text "=" <+> prettySe 10 v <+> text "in" $+$
920 nest nestingSize (prettySe 10 sc)
922 text "let" <+> pretty n <+> text "=" <+> prettySe 10 v <+> text "in" <+>
924 prettySe p (PPi (Exp l s _ _) n ty sc)
925 | n `elem` allNamesIn sc || impl =
926 let open = if l then text "|" <> lparen else lparen in
928 if size sc > breakingSize then
929 open <> pretty n <+> colon <+> prettySe 10 ty <> rparen <+>
930 st <+> text "->" $+$ prettySe 10 sc
932 open <> pretty n <+> colon <+> prettySe 10 ty <> rparen <+>
933 st <+> text "->" <+> prettySe 10 sc
936 if size sc > breakingSize then
937 prettySe 0 ty <+> st <+> text "->" $+$ prettySe 10 sc
939 prettySe 0 ty <+> st <+> text "->" <+> prettySe 10 sc
943 Static -> text "[static]"
945 prettySe p (PPi (Imp l s _ _) n ty sc)
947 let open = if l then text "|" <> lbrace else lbrace in
949 if size sc > breakingSize then
950 open <> pretty n <+> colon <+> prettySe 10 ty <> rbrace <+>
951 st <+> text "->" <+> prettySe 10 sc
953 open <> pretty n <+> colon <+> prettySe 10 ty <> rbrace <+>
954 st <+> text "->" <+> prettySe 10 sc
955 | otherwise = prettySe 10 sc
959 Static -> text $ "[static]"
961 prettySe p (PPi (Constraint _ _ _) n ty sc) =
963 if size sc > breakingSize then
964 prettySe 10 ty <+> text "=>" <+> prettySe 10 sc
966 prettySe 10 ty <+> text "=>" $+$ prettySe 10 sc
967 prettySe p (PPi (TacImp _ _ s _) n ty sc) =
969 if size sc > breakingSize then
970 lbrace <> text "tacimp" <+> pretty n <+> colon <+> prettySe 10 ty <>
971 rbrace <+> text "->" $+$ prettySe 10 sc
973 lbrace <> text "tacimp" <+> pretty n <+> colon <+> prettySe 10 ty <>
974 rbrace <+> text "->" <+> prettySe 10 sc
975 prettySe p (PApp _ (PRef _ f) [])
976 | not impl = pretty f
977 prettySe p (PAppBind _ (PRef _ f) [])
978 | not impl = text "!" <+> pretty f
979 prettySe p (PApp _ (PRef _ op@(UN (f:_))) args)
980 | length (getExps args) == 2 && (not impl) && (not $ isAlpha f) =
981 let [l, r] = getExps args in
983 if size r > breakingSize then
984 prettySe 1 l <+> pretty op $+$ prettySe 0 r
986 prettySe 1 l <+> pretty op <+> prettySe 0 r
987 prettySe p (PApp _ f as) =
988 let args = getExps as in
993 -- foldr (<+>) empty $ map prettyArgS as
995 foldl' fSe empty args
996 -- foldr (<+>) empty $ map prettyArgSe args
999 if size r > breakingSize then
1000 l $+$ nest nestingSize (prettyArgS r)
1005 if size r > breakingSize then
1006 l $+$ nest nestingSize (prettyArgSe r)
1009 prettySe p (PCase _ scr opts) =
1010 text "case" <+> prettySe 10 scr <+> text "of" $+$ nest nestingSize prettyBody
1012 prettyBody = foldr ($$) empty $ intersperse (text "|") $ map sc opts
1014 sc (l, r) = prettySe 10 l <+> text "=>" <+> prettySe 10 r
1015 prettySe p (PHidden tm) = text "." <> prettySe 0 tm
1016 prettySe p (PRefl _ _) = text "refl"
1017 prettySe p (PResolveTC _) = text "resolvetc"
1018 prettySe p (PTrue _) = text "()"
1019 prettySe p (PFalse _) = text "_|_"
1020 prettySe p (PEq _ l r) =
1022 if size r > breakingSize then
1023 prettySe 10 l <+> text "=" $$ nest nestingSize (prettySe 10 r)
1025 prettySe 10 l <+> text "=" <+> prettySe 10 r
1026 prettySe p (PRewrite _ l r _) =
1028 if size r > breakingSize then
1029 text "rewrite" <+> prettySe 10 l <+> text "in" $$ nest nestingSize (prettySe 10 r)
1031 text "rewrite" <+> prettySe 10 l <+> text "in" <+> prettySe 10 r
1032 prettySe p (PTyped l r) =
1033 lparen <> prettySe 10 l <+> colon <+> prettySe 10 r <> rparen
1034 prettySe p (PPair _ l r) =
1035 if size r > breakingSize then
1036 lparen <> prettySe 10 l <> text "," $+$
1037 prettySe 10 r <> rparen
1039 lparen <> prettySe 10 l <> text "," <+> prettySe 10 r <> rparen
1040 prettySe p (PDPair _ l t r) =
1041 if size r > breakingSize then
1042 lparen <> prettySe 10 l <+> text "**" $+$
1043 prettySe 10 r <> rparen
1045 lparen <> prettySe 10 l <+> text "**" <+> prettySe 10 r <> rparen
1046 prettySe p (PAlternative a as) =
1047 lparen <> text "|" <> prettyAs <> text "|" <> rparen
1050 foldr (\l -> \r -> l <+> text "," <+> r) empty $ map (prettySe 10) as
1051 prettySe p PType = text "Type"
1052 prettySe p (PConstant c) = pretty c
1053 -- XXX: add pretty for tactics
1054 prettySe p (PProof ts) =
1055 text "proof" <+> lbrace $+$ nest nestingSize (text . show $ ts) $+$ rbrace
1056 prettySe p (PTactics ts) =
1057 text "tactics" <+> lbrace $+$ nest nestingSize (text . show $ ts) $+$ rbrace
1058 prettySe p (PMetavar n) = text "?" <> pretty n
1059 prettySe p (PReturn f) = text "return"
1060 prettySe p PImpossible = text "impossible"
1061 prettySe p Placeholder = text "_"
1062 prettySe p (PDoBlock _) = text "do block pretty not implemented"
1063 prettySe p (PElabError s) = pretty s
1065 prettySe p _ = text "test"
1067 prettyArgS (PImp _ _ _ n tm _) = prettyArgSi (n, tm)
1068 prettyArgS (PExp _ _ tm _) = prettyArgSe tm
1069 prettyArgS (PConstraint _ _ tm _) = prettyArgSc tm
1070 prettyArgS (PTacImplicit _ _ n _ tm _) = prettyArgSti (n, tm)
1072 prettyArgSe arg = prettySe 0 arg
1073 prettyArgSi (n, val) = lbrace <> pretty n <+> text "=" <+> prettySe 10 val <> rbrace
1074 prettyArgSc val = lbrace <> lbrace <> prettySe 10 val <> rbrace <> rbrace
1075 prettyArgSti (n, val) = lbrace <> text "auto" <+> pretty n <+> text "=" <+> prettySe 10 val <> rbrace
1077 bracket outer inner doc
1078 | inner > outer = lparen <> doc <> rparen
1082showName :: Maybe IState -- ^^ the Idris state, for information about names and colours
1083 -> [(Name, Bool)] -- ^^ the bound variables and whether they're implicit
1084 -> Bool -- ^^ whether to show implicits
1085 -> Bool -- ^^ whether to colourise
1086 -> Name -- ^^ the term to show
1088showName ist bnd impl colour n = case ist of
1089 Just i -> if colour then colourise n (idris_colourTheme i) else showbasic n
1090 Nothing -> showbasic n
1091 where name = if impl then show n else showbasic n
1092 showbasic n@(UN _) = show n
1093 showbasic (MN _ s) = s
1094 showbasic (NS n s) = showSep "." (reverse s) ++ "." ++ showbasic n
1095 showbasic (SN s) = show s
1097 colourise n t = let ctxt' = fmap tt_ctxt ist in
1100 Just ctxt | Just impl <- lookup n bnd -> if impl then colouriseImplicit t name
1101 else colouriseBound t name
1102 | isDConName n ctxt -> colouriseData t name
1103 | isFnName n ctxt -> colouriseFun t name
1104 | isTConName n ctxt -> colouriseType t name
1105 -- The assumption is that if a name is not bound and does not exist in the
1106 -- global context, then we're somewhere in which implicit info has been lost
1107 -- (like error messages). Thus, unknown vars are colourised as implicits.
1108 | otherwise -> colouriseImplicit t name
1111showImp :: Maybe IState -- ^^ the Idris state, for information about identifiers and colours
1112 -> Bool -- ^^ whether to show implicits
1113 -> Bool -- ^^ whether to colourise
1114 -> PTerm -- ^^ the term to show
1116showImp ist impl colour tm = se 10 [] tm where
1117 perhapsColourise :: (ColourTheme -> String -> String) -> String -> String
1118 perhapsColourise col str = case ist of
1119 Just i -> if colour then col (idris_colourTheme i) str else str
1122 se :: Int -> [(Name, Bool)] -> PTerm -> String
1123 se p bnd (PQuote r) = "![" ++ show r ++ "]"
1124 se p bnd (PPatvar fc n) = if impl then show n ++ "[p]" else show n
1125 se p bnd (PInferRef fc n) = "!" ++ show n -- ++ "[" ++ show fc ++ "]"
1127 | Just str <- slist p bnd e = str
1128 | Just num <- snat p e = perhapsColourise colouriseData (show num)
1129 se p bnd (PRef fc n) = showName ist bnd impl colour n
1130 se p bnd (PLam n ty sc) = bracket p 2 $ "\\ " ++ perhapsColourise colouriseBound (show n) ++
1131 (if impl then " : " ++ se 10 bnd ty else "") ++ " => "
1132 ++ se 10 ((n, False):bnd) sc
1133 se p bnd (PLet n ty v sc) = bracket p 2 $ "let " ++ perhapsColourise colouriseBound (show n) ++
1134 " = " ++ se 10 bnd v ++
1135 " in " ++ se 10 ((n, False):bnd) sc
1136 se p bnd (PPi (Exp l s _ param) n ty sc)
1137 | n `elem` allNamesIn sc || impl
1139 (if l then "|(" else "(") ++
1140 perhapsColourise colouriseBound (show n) ++ " : " ++ se 10 bnd ty ++
1142 (if (impl && param) then "P" else "") ++
1144 "-> " ++ se 10 ((n, False):bnd) sc
1145 | otherwise = bracket p 2 $ se 0 bnd ty ++ " " ++ st ++ "-> " ++ se 10 bnd sc
1146 where st = case s of
1147 Static -> "[static] "
1149 se p bnd (PPi (Imp l s _ _) n ty sc)
1150 | impl = bracket p 2 $ (if l then "|{" else "{") ++
1151 perhapsColourise colouriseBound (show n) ++ " : " ++ se 10 bnd ty ++
1152 "} " ++ st ++ "-> " ++ se 10 ((n, True):bnd) sc
1153 | otherwise = se 10 ((n, True):bnd) sc
1154 where st = case s of
1155 Static -> "[static] "
1157 se p bnd (PPi (Constraint _ _ _) n ty sc)
1158 = bracket p 2 $ se 10 bnd ty ++ " => " ++ se 10 bnd sc
1159 se p bnd (PPi (TacImp _ _ s _) n ty sc)
1161 "{tacimp " ++ (perhapsColourise colouriseBound (show n)) ++ " : " ++ se 10 bnd ty ++ "} -> " ++
1162 se 10 ((n, False):bnd) sc
1163 se p bnd (PMatchApp _ f) = "match " ++ show f
1164 se p bnd (PApp _ hd@(PRef _ f) [])
1165 | not impl = se p bnd hd
1166 se p bnd (PAppBind _ hd@(PRef _ f) [])
1167 | not impl = "!" ++ se p bnd hd
1168 se p bnd (PApp _ op@(PRef _ (UN (f:_))) args)
1169 | length (getExps args) == 2 && not impl && not (isAlpha f)
1170 = let [l, r] = getExps args in
1171 bracket p 1 $ se 1 bnd l ++ " " ++ se p bnd op ++ " " ++ se 0 bnd r
1172 se p bnd (PApp _ f as)
1173 = -- let args = getExps as in
1174 bracket p 1 $ se 1 bnd f ++
1175 if impl then concatMap (sArg bnd) as
1176 else concatMap (suiArg impl bnd) as
1177 se p bnd (PAppBind _ f as)
1178 = let args = getExps as in
1179 "!" ++ (bracket p 1 $ se 1 bnd f ++ if impl then concatMap (sArg bnd) as
1180 else concatMap (seArg bnd) args)
1181 se p bnd (PCase _ scr opts) = "case " ++ se 10 bnd scr ++ " of " ++ showSep " | " (map sc opts)
1182 where sc (l, r) = se 10 bnd l ++ " => " ++ se 10 bnd r
1183 se p bnd (PHidden tm) = "." ++ se 0 bnd tm
1184 se p bnd (PRefl _ t)
1185 | not impl = perhapsColourise colouriseData "refl"
1186 | otherwise = perhapsColourise colouriseData $ "refl {" ++ se 10 bnd t ++ "}"
1187 se p bnd (PResolveTC _) = "resolvetc"
1188 se p bnd (PTrue _) = perhapsColourise colouriseType "()"
1189 se p bnd (PFalse _) = perhapsColourise colouriseType "_|_"
1190 se p bnd (PEq _ l r) = bracket p 2 $ se 10 bnd l ++ perhapsColourise colouriseType " = " ++ se 10 bnd r
1191 se p bnd (PRewrite _ l r _) = bracket p 2 $ "rewrite " ++ se 10 bnd l ++ " in " ++ se 10 bnd r
1192 se p bnd (PTyped l r) = "(" ++ se 10 bnd l ++ " : " ++ se 10 bnd r ++ ")"
1193 se p bnd (PPair _ l r) = "(" ++ se 10 bnd l ++ ", " ++ se 10 bnd r ++ ")"
1194 se p bnd (PDPair _ l t r) = "(" ++ se 10 bnd l ++ " ** " ++ se 10 bnd r ++ ")"
1195 se p bnd (PAlternative a as) = "(|" ++ showSep " , " (map (se 10 bnd) as) ++ "|)"
1196 se p bnd PType = perhapsColourise colouriseType "Type"
1197 se p bnd (PConstant c) = perhapsColourise (cfun c) (show c)
1198 where cfun (AType _) = colouriseType
1199 cfun StrType = colouriseType
1200 cfun PtrType = colouriseType
1201 cfun VoidType = colouriseType
1202 cfun _ = colouriseData
1203 se p bnd (PProof ts) = "proof { " ++ show ts ++ "}"
1204 se p bnd (PTactics ts) = "tactics { " ++ show ts ++ "}"
1205 se p bnd (PMetavar n) = "?" ++ show n
1206 se p bnd (PReturn f) = "return"
1207 se p bnd PImpossible = "impossible"
1208 se p bnd Placeholder = "_"
1209 se p bnd (PDoBlock _) = "do block show not implemented"
1210 se p bnd (PElabError s) = show s
1211 se p bnd (PCoerced t) = se p bnd t
1212 se p bnd (PUnifyLog t) = "%unifyLog " ++ se p bnd t
1213 se p bnd (PNoImplicits t) = "%noimplicit " ++ se p bnd t
1214-- se p bnd x = "Not implemented"
1216 slist' p bnd (PApp _ (PRef _ nil) _)
1217 | nsroot nil == UN "Nil" = Just []
1218 slist' p bnd (PApp _ (PRef _ cons) args)
1219 | nsroot cons == UN "::",
1220 (PExp {getTm=tl}):(PExp {getTm=hd}):imps <- reverse args,
1222 Just tl' <- slist' p bnd tl
1225 isImp (PImp {}) = True
1227 slist' _ _ _ = Nothing
1229 slist p bnd e | Just es <- slist' p bnd e = Just $
1230 case es of [] -> "[]"
1231 [x] -> "[" ++ se p bnd x ++ "]"
1232 xs -> "[" ++ intercalate "," (map (se p bnd ) xs) ++ "]"
1233 slist _ _ _ = Nothing
1235 -- since Prelude is always imported, S & Z are unqualified iff they're the
1238 | show o == (natns++"Z") || show o == "Z" = Just 0
1239 snat p (PApp _ s [PExp {getTm=n}])
1240 | show s == (natns++"S") || show s == "S",
1245 natns = "Prelude.Nat."
1247 sArg bnd (PImp _ _ _ n tm _) = siArg bnd (n, tm)
1248 sArg bnd (PExp _ _ tm _) = seArg bnd tm
1249 sArg bnd (PConstraint _ _ tm _) = scArg bnd tm
1250 sArg bnd (PTacImplicit _ _ n _ tm _) = stiArg bnd (n, tm)
1252 -- show argument, implicits given by the user also shown
1253 suiArg impl bnd (PImp _ mi _ n tm _)
1254 | impl || not mi = siArg bnd (n, tm)
1255 suiArg impl bnd (PExp _ _ tm _) = seArg bnd tm
1256 suiArg impl bnd _ = ""
1258 seArg bnd arg = " " ++ se 0 bnd arg
1259 siArg bnd (n, val) =
1261 val' = se 10 bnd val in
1263 then " {" ++ n' ++ "}"
1264 else " {" ++ n' ++ " = " ++ val' ++ "}"
1265 scArg bnd val = " {{" ++ se 10 bnd val ++ "}}"
1266 stiArg bnd (n, val) = " {auto " ++ show n ++ " = " ++ se 10 bnd val ++ "}"
1268 bracket outer inner str | inner > outer = "(" ++ str ++ ")"
1272instance Sized PTerm where
1273 size (PQuote rawTerm) = size rawTerm
1274 size (PRef fc name) = size name
1275 size (PLam name ty bdy) = 1 + size ty + size bdy
1276 size (PPi plicity name ty bdy) = 1 + size ty + size bdy
1277 size (PLet name ty def bdy) = 1 + size ty + size def + size bdy
1278 size (PTyped trm ty) = 1 + size trm + size ty
1279 size (PApp fc name args) = 1 + size args
1280 size (PAppBind fc name args) = 1 + size args
1281 size (PCase fc trm bdy) = 1 + size trm + size bdy
1283 size (PFalse fc) = 1
1284 size (PRefl fc _) = 1
1285 size (PResolveTC fc) = 1
1286 size (PEq fc left right) = 1 + size left + size right
1287 size (PRewrite fc left right _) = 1 + size left + size right
1288 size (PPair fc left right) = 1 + size left + size right
1289 size (PDPair fs left ty right) = 1 + size left + size ty + size right
1290 size (PAlternative a alts) = 1 + size alts
1291 size (PHidden hidden) = size hidden
1292 size (PUnifyLog tm) = size tm
1293 size (PNoImplicits tm) = size tm
1295 size (PConstant const) = 1 + size const
1296 size Placeholder = 1
1297 size (PDoBlock dos) = 1 + size dos
1298 size (PIdiom fc term) = 1 + size term
1299 size (PReturn fc) = 1
1300 size (PMetavar name) = 1
1301 size (PProof tactics) = size tactics
1302 size (PElabError err) = size err
1303 size PImpossible = 1
1305getPArity :: PTerm -> Int
1306getPArity (PPi _ _ _ sc) = 1 + getPArity sc
1309-- Return all names, free or globally bound, in the given term.
1311allNamesIn :: PTerm -> [Name]
1312allNamesIn tm = nub $ ni [] tm
1315 | not (n `elem` env) = [n]
1316 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1317 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1318 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1319 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1320 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
1321 ni env (PHidden tm) = ni env tm
1322 ni env (PEq _ l r) = ni env l ++ ni env r
1323 ni env (PRewrite _ l r _) = ni env l ++ ni env r
1324 ni env (PTyped l r) = ni env l ++ ni env r
1325 ni env (PPair _ l r) = ni env l ++ ni env r
1326 ni env (PDPair _ (PRef _ n) t r) = ni env t ++ ni (n:env) r
1327 ni env (PDPair _ l t r) = ni env l ++ ni env t ++ ni env r
1328 ni env (PAlternative a ls) = concatMap (ni env) ls
1329 ni env (PUnifyLog tm) = ni env tm
1330 ni env (PNoImplicits tm) = ni env tm
1333-- Return names which are free in the given term.
1335namesIn :: [(Name, PTerm)] -> IState -> PTerm -> [Name]
1336namesIn uvars ist tm = nub $ ni [] tm
1339 | not (n `elem` env)
1340 = case lookupTy n (tt_ctxt ist) of
1342 _ -> if n `elem` (map fst uvars) then [n] else []
1343 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1344 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1345 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1346 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1347 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
1348 ni env (PEq _ l r) = ni env l ++ ni env r
1349 ni env (PRewrite _ l r _) = ni env l ++ ni env r
1350 ni env (PTyped l r) = ni env l ++ ni env r
1351 ni env (PPair _ l r) = ni env l ++ ni env r
1352 ni env (PDPair _ (PRef _ n) t r) = ni env t ++ ni (n:env) r
1353 ni env (PDPair _ l t r) = ni env l ++ ni env t ++ ni env r
1354 ni env (PAlternative a as) = concatMap (ni env) as
1355 ni env (PHidden tm) = ni env tm
1356 ni env (PUnifyLog tm) = ni env tm
1357 ni env (PNoImplicits tm) = ni env tm
1360-- Return which of the given names are used in the given term.
1362usedNamesIn :: [Name] -> IState -> PTerm -> [Name]
1363usedNamesIn vars ist tm = nub $ ni [] tm
1366 | n `elem` vars && not (n `elem` env)
1367 = case lookupTy n (tt_ctxt ist) of
1370 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1371 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1372 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1373 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1374 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
1375 ni env (PEq _ l r) = ni env l ++ ni env r
1376 ni env (PRewrite _ l r _) = ni env l ++ ni env r
1377 ni env (PTyped l r) = ni env l ++ ni env r
1378 ni env (PPair _ l r) = ni env l ++ ni env r
1379 ni env (PDPair _ (PRef _ n) t r) = ni env t ++ ni (n:env) r
1380 ni env (PDPair _ l t r) = ni env l ++ ni env t ++ ni env r
1381 ni env (PAlternative a as) = concatMap (ni env) as
1382 ni env (PHidden tm) = ni env tm
1383 ni env (PUnifyLog tm) = ni env tm
1384 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