1{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, DeriveFunctor,
2 TypeSynonymInstances, PatternGuards #-}
4module Idris.AbsSyntax(module Idris.AbsSyntax, module Idris.AbsSyntaxTree) where
8import Core.Elaborate hiding (Tactic(..))
10import Idris.AbsSyntaxTree
12import IRTS.CodegenCommon
13import Util.DynamicLinker
17import System.Console.Haskeline
19import Control.Monad.State
30getContext :: Idris Context
31getContext = do i <- getIState; return (tt_ctxt i)
33getObjectFiles :: Idris [FilePath]
34getObjectFiles = do i <- getIState; return (idris_objs i)
36addObjectFile :: FilePath -> Idris ()
37addObjectFile f = do i <- getIState; putIState $ i { idris_objs = f : idris_objs i }
39getLibs :: Idris [String]
40getLibs = do i <- getIState; return (idris_libs i)
42addLib :: String -> Idris ()
43addLib f = do i <- getIState; putIState $ i { idris_libs = f : idris_libs i }
45addDyLib :: [String] -> Idris (Either DynamicLib String)
46addDyLib libs = do i <- getIState
47 handle <- lift $ mapM (\l -> catchIO (tryLoadLib l) (\_ -> return Nothing)) libs
49 Nothing -> return (Right $ "Could not load dynamic alternatives \"" ++
50 concat (intersperse "," libs) ++ "\"")
51 Just x -> do let ls = idris_dynamic_libs i
52 putIState $ i { idris_dynamic_libs = x:ls }
55addHdr :: String -> Idris ()
56addHdr f = do i <- getIState; putIState $ i { idris_hdrs = f : idris_hdrs i }
58addLangExt :: LanguageExt -> Idris ()
59addLangExt TypeProviders = do i <- getIState ; putIState $ i { idris_language_extensions = [TypeProviders] }
61totcheck :: (FC, Name) -> Idris ()
62totcheck n = do i <- getIState; putIState $ i { idris_totcheck = idris_totcheck i ++ [n] }
64setFlags :: Name -> [FnOpt] -> Idris ()
65setFlags n fs = do i <- getIState; putIState $ i { idris_flags = addDef n fs (idris_flags i) }
67setAccessibility :: Name -> Accessibility -> Idris ()
70 let ctxt = setAccess n a (tt_ctxt i)
71 putIState $ i { tt_ctxt = ctxt }
73setTotality :: Name -> Totality -> Idris ()
76 let ctxt = setTotal n a (tt_ctxt i)
77 putIState $ i { tt_ctxt = ctxt }
79getTotality :: Name -> Idris Totality
82 case lookupTotal n (tt_ctxt i) of
84 _ -> return (Total [])
86-- Get coercions which might return the required type
87getCoercionsTo :: IState -> Type -> [Name]
89 let cs = idris_coercions i
90 (fn,_) = unApply (getRetTy ty) in
92 where findCoercions t [] = []
93 findCoercions t (n : ns) =
94 let ps = case lookupTy n (tt_ctxt i) of
95 [ty] -> case unApply (getRetTy ty) of
97 if t == t' then [n] else []
99 ps ++ findCoercions t ns
101addToCG :: Name -> CGInfo -> Idris ()
104 putIState $ i { idris_callgraph = addDef n cg (idris_callgraph i) }
106addCoercion :: Name -> Idris ()
107addCoercion n = do i <- getIState
108 putIState $ i { idris_coercions = n : idris_coercions i }
110addDocStr :: Name -> String -> Idris ()
113 putIState $ i { idris_docstrings = addDef n doc (idris_docstrings i) }
115addToCalledG :: Name -> [Name] -> Idris ()
116addToCalledG n ns = return () -- TODO
118-- Add a class instance function. Dodgy hack: Put integer instances first in the
119-- list so they are resolved by default.
120-- Dodgy hack 2: put constraint chasers (@@) last
122addInstance :: Bool -> Name -> Name -> Idris ()
124 = do ist <- getIState
125 case lookupCtxt n (idris_classes ist) of
127 do let cs = addDef n (CI a b c d (addI i ins)) (idris_classes ist)
128 putIState $ ist { idris_classes = cs }
129 _ -> do let cs = addDef n (CI (MN 0 "none") [] [] [] [i]) (idris_classes ist)
130 putIState $ ist { idris_classes = cs }
131 where addI i ins | int = i : ins
132 | chaser n = ins ++ [i]
133 | otherwise = insI i ins
135 insI i (n : ns) | chaser n = i : n : ns
136 | otherwise = n : insI i ns
138 chaser (UN ('@':'@':_)) = True
139 chaser (NS n _) = chaser n
142addClass :: Name -> ClassInfo -> Idris ()
144 = do ist <- getIState
145 let i' = case lookupCtxt n (idris_classes ist) of
146 [c] -> c { class_instances = class_instances i }
148 putIState $ ist { idris_classes = addDef n i' (idris_classes ist) }
150addIBC :: IBCWrite -> Idris ()
153 when (notDef (ibc_write i)) $
154 putIState $ i { ibc_write = ibc : ibc_write i }
155 where notDef [] = True
156 notDef (IBCDef n': is) | n == n' = False
157 notDef (_ : is) = notDef is
158addIBC ibc = do i <- getIState; putIState $ i { ibc_write = ibc : ibc_write i }
161clearIBC = do i <- getIState; putIState $ i { ibc_write = [] }
163getHdrs :: Idris [String]
164getHdrs = do i <- getIState; return (idris_hdrs i)
166setErrLine :: Int -> Idris ()
167setErrLine x = do i <- getIState;
169 Nothing -> putIState $ i { errLine = Just x }
173clearErr = do i <- getIState
174 putIState $ i { errLine = Nothing }
176getSO :: Idris (Maybe String)
177getSO = do i <- getIState
178 return (compiled_so i)
180setSO :: Maybe String -> Idris ()
181setSO s = do i <- getIState
182 putIState $ (i { compiled_so = s })
184getIState :: Idris IState
187putIState :: IState -> Idris ()
191getName = do i <- getIState;
192 let idx = idris_name i;
193 putIState $ (i { idris_name = idx + 1 })
196checkUndefined :: FC -> Name -> Idris ()
200 (_:_) -> fail $ show fc ++ ":" ++
201 show n ++ " already defined"
204isUndefined :: FC -> Name -> Idris Bool
208 (_:_) -> return False
211setContext :: Context -> Idris ()
212setContext ctxt = do i <- getIState; putIState $ (i { tt_ctxt = ctxt } )
214updateContext :: (Context -> Context) -> Idris ()
215updateContext f = do i <- getIState; putIState $ (i { tt_ctxt = f (tt_ctxt i) } )
217addConstraints :: FC -> (Int, [UConstraint]) -> Idris ()
218addConstraints fc (v, cs)
221 let ctxt' = ctxt { uconstraints = cs ++ uconstraints ctxt,
223 let ics = zip cs (repeat fc) ++ idris_constraints i
224 putIState $ i { tt_ctxt = ctxt', idris_constraints = ics }
226addDeferred = addDeferred' Ref
227addDeferredTyCon = addDeferred' (TCon 0 0)
229addDeferred' :: NameType -> [(Name, Type)] -> Idris ()
231 = do mapM_ (\(n, t) -> updateContext (addTyDecl n nt (tidyNames [] t))) ns
233 putIState $ i { idris_metavars = map fst ns ++ idris_metavars i }
234 where tidyNames used (Bind (MN i x) b sc)
235 = let n' = uniqueName (UN x) used in
236 Bind n' b $ tidyNames (n':used) sc
237 tidyNames used (Bind n b sc)
238 = let n' = uniqueName n used in
239 Bind n' b $ tidyNames (n':used) sc
242solveDeferred :: Name -> Idris ()
243solveDeferred n = do i <- getIState
244 putIState $ i { idris_metavars = idris_metavars i \\ [n] }
246iResult :: String -> Idris ()
247iResult s = do i <- getIState
248 case idris_outputmode i of
249 RawOutput -> case s of
251 s -> liftIO $ putStrLn s
253 let good = SexpList [SymbolAtom "ok", toSExp s] in
254 liftIO $ putStrLn $ convSExp "return" good n
256iFail :: String -> Idris ()
257iFail s = do i <- getIState
258 case idris_outputmode i of
259 RawOutput -> case s of
261 s -> liftIO $ putStrLn s
263 let good = SexpList [SymbolAtom "error", toSExp s] in
264 liftIO $ putStrLn $ convSExp "return" good n
266iputStrLn :: String -> Idris ()
267iputStrLn s = do i <- getIState
268 case idris_outputmode i of
269 RawOutput -> liftIO $ putStrLn s
271 case span (/=':') s of
272 (fn, ':':rest) -> case span isDigit rest of
273 ([], ':':msg) -> write
275 (num, ':':msg) -> iWarn (FC fn (read num)) msg
277 where write = liftIO $ putStrLn $ convSExp "write-string" s n
279iWarn :: FC -> String -> Idris ()
280iWarn fc err = do i <- getIState
281 case idris_outputmode i of
282 RawOutput -> liftIO $ putStrLn (show fc ++ ":" ++ err)
283 IdeSlave n -> liftIO $ putStrLn $ convSExp "warning" (fc_fname fc, fc_line fc, err) n
285setLogLevel :: Int -> Idris ()
286setLogLevel l = do i <- getIState
287 let opts = idris_options i
288 let opt' = opts { opt_logLevel = l }
289 putIState $ i { idris_options = opt' }
291setCmdLine :: [Opt] -> Idris ()
292setCmdLine opts = do i <- getIState
293 let iopts = idris_options i
294 putIState $ i { idris_options = iopts { opt_cmdline = opts } }
296getDumpDefun :: Idris (Maybe FilePath)
297getDumpDefun = do i <- getIState
298 return $ findC (opt_cmdline (idris_options i))
299 where findC [] = Nothing
300 findC (DumpDefun x : _) = Just x
301 findC (_ : xs) = findC xs
303getDumpCases :: Idris (Maybe FilePath)
304getDumpCases = do i <- getIState
305 return $ findC (opt_cmdline (idris_options i))
306 where findC [] = Nothing
307 findC (DumpCases x : _) = Just x
308 findC (_ : xs) = findC xs
311logLevel = do i <- getIState
312 return (opt_logLevel (idris_options i))
314setErrContext :: Bool -> Idris ()
315setErrContext t = do i <- getIState
316 let opts = idris_options i
317 let opt' = opts { opt_errContext = t }
318 putIState $ i { idris_options = opt' }
320errContext :: Idris Bool
321errContext = do i <- getIState
322 return (opt_errContext (idris_options i))
325useREPL = do i <- getIState
326 return (opt_repl (idris_options i))
328setREPL :: Bool -> Idris ()
329setREPL t = do i <- getIState
330 let opts = idris_options i
331 let opt' = opts { opt_repl = t }
332 putIState $ i { idris_options = opt' }
334setQuiet :: Bool -> Idris ()
335setQuiet q = do i <- getIState
336 let opts = idris_options i
337 let opt' = opts { opt_quiet = q }
338 putIState $ i { idris_options = opt' }
340setTarget :: Target -> Idris ()
341setTarget t = do i <- getIState
342 let opts = idris_options i
343 let opt' = opts { opt_target = t }
344 putIState $ i { idris_options = opt' }
346target :: Idris Target
347target = do i <- getIState
348 return (opt_target (idris_options i))
350setOutputTy :: OutputType -> Idris ()
351setOutputTy t = do i <- getIState
352 let opts = idris_options i
353 let opt' = opts { opt_outputTy = t }
354 putIState $ i { idris_options = opt' }
356outputTy :: Idris OutputType
357outputTy = do i <- getIState
358 return $ opt_outputTy $ idris_options i
360setIdeSlave :: Bool -> Idris ()
361setIdeSlave True = do i <- getIState
362 putIState $ i { idris_outputmode = (IdeSlave 0) }
363setIdeSlave False = return ()
366verbose = do i <- getIState
367 return (opt_verbose (idris_options i))
369setVerbose :: Bool -> Idris ()
370setVerbose t = do i <- getIState
371 let opts = idris_options i
372 let opt' = opts { opt_verbose = t }
373 putIState $ i { idris_options = opt' }
375typeInType :: Idris Bool
376typeInType = do i <- getIState
377 return (opt_typeintype (idris_options i))
379setTypeInType :: Bool -> Idris ()
380setTypeInType t = do i <- getIState
381 let opts = idris_options i
382 let opt' = opts { opt_typeintype = t }
383 putIState $ i { idris_options = opt' }
385coverage :: Idris Bool
386coverage = do i <- getIState
387 return (opt_coverage (idris_options i))
389setCoverage :: Bool -> Idris ()
390setCoverage t = do i <- getIState
391 let opts = idris_options i
392 let opt' = opts { opt_coverage = t }
393 putIState $ i { idris_options = opt' }
395setIBCSubDir :: FilePath -> Idris ()
396setIBCSubDir fp = do i <- getIState
397 let opts = idris_options i
398 let opt' = opts { opt_ibcsubdir = fp }
399 putIState $ i { idris_options = opt' }
401valIBCSubDir :: IState -> Idris FilePath
402valIBCSubDir i = return (opt_ibcsubdir (idris_options i))
404addImportDir :: FilePath -> Idris ()
405addImportDir fp = do i <- getIState
406 let opts = idris_options i
407 let opt' = opts { opt_importdirs = fp : opt_importdirs opts }
408 putIState $ i { idris_options = opt' }
410setImportDirs :: [FilePath] -> Idris ()
411setImportDirs fps = do i <- getIState
412 let opts = idris_options i
413 let opt' = opts { opt_importdirs = fps }
414 putIState $ i { idris_options = opt' }
416allImportDirs :: IState -> Idris [FilePath]
417allImportDirs i = do let optdirs = opt_importdirs (idris_options i)
418 return ("." : reverse optdirs)
421impShow = do i <- getIState
422 return (opt_showimp (idris_options i))
424setImpShow :: Bool -> Idris ()
425setImpShow t = do i <- getIState
426 let opts = idris_options i
427 let opt' = opts { opt_showimp = t }
428 putIState $ i { idris_options = opt' }
430logLvl :: Int -> String -> Idris ()
431logLvl l str = do i <- getIState
432 let lvl = opt_logLevel (idris_options i)
434 $ do liftIO (putStrLn str)
435 putIState $ i { idris_log = idris_log i ++ str ++ "\n" }
437cmdOptType :: Opt -> Idris Bool
438cmdOptType x = do i <- getIState
439 return $ x `elem` opt_cmdline (idris_options i)
441iLOG :: String -> Idris ()
444noErrors :: Idris Bool
445noErrors = do i <- getIState
447 Nothing -> return True
450setTypeCase :: Bool -> Idris ()
451setTypeCase t = do i <- getIState
452 let opts = idris_options i
453 let opt' = opts { opt_typecase = t }
454 putIState $ i { idris_options = opt' }
457-- For inferring types of things
461inferTy = MN 0 "__Infer"
462inferCon = MN 0 "__infer"
463inferDecl = PDatadecl inferTy
465 [("", inferCon, PPi impl (MN 0 "A") PType (
466 PPi expl (MN 0 "a") (PRef bi (MN 0 "A"))
467 (PRef bi inferTy)), bi)]
469infTerm t = PApp bi (PRef bi inferCon) [pimp (MN 0 "A") Placeholder, pexp t]
470infP = P (TCon 6 0) inferTy (TType (UVal 0))
472getInferTerm, getInferType :: Term -> Term
473getInferTerm (Bind n b sc) = Bind n b $ getInferTerm sc
474getInferTerm (App (App _ _) tm) = tm
475getInferTerm tm = tm -- error ("getInferTerm " ++ show tm)
477getInferType (Bind n b sc) = Bind n b $ getInferType sc
478getInferType (App (App _ ty) _) = ty
480-- Handy primitives: Unit, False, Pair, MkPair, =, mkForeign
482primNames = [unitTy, unitCon,
483 falseTy, pairTy, pairCon,
484 eqTy, eqCon, inferTy, inferCon]
486unitTy = MN 0 "__Unit"
488unitDecl = PDatadecl unitTy PType
489 [("", unitCon, PRef bi unitTy, bi)]
491falseTy = MN 0 "__False"
492falseDecl = PDatadecl falseTy PType []
494pairTy = MN 0 "__Pair"
495pairCon = MN 0 "__MkPair"
496pairDecl = PDatadecl pairTy (piBind [(n "A", PType), (n "B", PType)] PType)
497 [("", pairCon, PPi impl (n "A") PType (
498 PPi impl (n "B") PType (
499 PPi expl (n "a") (PRef bi (n "A")) (
500 PPi expl (n "b") (PRef bi (n "B"))
501 (PApp bi (PRef bi pairTy) [pexp (PRef bi (n "A")),
502 pexp (PRef bi (n "B"))])))), bi)]
507eqDecl = PDatadecl eqTy (piBind [(n "a", PType), (n "b", PType),
508 (n "x", PRef bi (n "a")), (n "y", PRef bi (n "b"))]
510 [("", eqCon, PPi impl (n "a") PType (
511 PPi impl (n "x") (PRef bi (n "a"))
512 (PApp bi (PRef bi eqTy) [pimp (n "a") Placeholder,
513 pimp (n "b") Placeholder,
514 pexp (PRef bi (n "x")),
515 pexp (PRef bi (n "x"))])), bi)]
518-- Defined in builtins.idr
520existsCon = UN "Ex_intro"
522piBind :: [(Name, PTerm)] -> PTerm -> PTerm
525piBindp :: Plicity -> [(Name, PTerm)] -> PTerm -> PTerm
527piBindp p ((n, ty):ns) t = PPi p n ty (piBind ns t)
529-- Dealing with parameters
531expandParams :: (Name -> Name) -> [(Name, PTerm)] ->
532 [Name] -> -- all names
533 [Name] -> -- names with no declaration
535expandParams dec ps ns infs tm = en tm
537 -- if we shadow a name (say in a lambda binding) that is used in a call to
538 -- a lifted function, we need access to both names - once in the scope of the
539 -- binding and once to call the lifted functions. So we'll explicitly shadow
540 -- it. (Yes, it's a hack. The alternative would be to resolve names earlier
543 mkShadow (UN n) = MN 0 n
544 mkShadow (MN i n) = MN (i+1) n
545 mkShadow (NS x s) = NS (mkShadow x) s
548 | n `elem` map fst ps
549 = let n' = mkShadow n in
550 PLam n' (en t) (en (shadow n n' s))
551 | otherwise = PLam n (en t) (en s)
553 | n `elem` map fst ps
554 = let n' = mkShadow n in
555 PPi p n' (en t) (en (shadow n n' s))
556 | otherwise = PPi p n (en t) (en s)
558 | n `elem` map fst ps
559 = let n' = mkShadow n in
560 PLet n' (en ty) (en v) (en (shadow n n' s))
561 | otherwise = PLet n (en ty) (en v) (en s)
562 en (PEq f l r) = PEq f (en l) (en r)
563 en (PRewrite f l r) = PRewrite f (en l) (en r)
564 en (PTyped l r) = PTyped (en l) (en r)
565 en (PPair f l r) = PPair f (en l) (en r)
566 en (PDPair f l t r) = PDPair f (en l) (en t) (en r)
567 en (PAlternative a as) = PAlternative a (map en as)
568 en (PHidden t) = PHidden (en t)
569 en (PDoBlock ds) = PDoBlock (map (fmap en) ds)
570 en (PProof ts) = PProof (map (fmap en) ts)
571 en (PTactics ts) = PTactics (map (fmap en) ts)
574 | n `nselem` ns = PQuote (Var (dec n))
575 en (PApp fc (PInferRef fc' n) as)
576 | n `nselem` ns = PApp fc (PInferRef fc' (dec n))
577 (map (pexp . (PRef fc)) (map fst ps) ++ (map (fmap en) as))
578 en (PApp fc (PRef fc' n) as)
579 | n `elem` infs = PApp fc (PInferRef fc' (dec n))
580 (map (pexp . (PRef fc)) (map fst ps) ++ (map (fmap en) as))
581 | n `nselem` ns = PApp fc (PRef fc' (dec n))
582 (map (pexp . (PRef fc)) (map fst ps) ++ (map (fmap en) as))
584 | n `elem` infs = PApp fc (PInferRef fc (dec n))
585 (map (pexp . (PRef fc)) (map fst ps))
586 | n `nselem` ns = PApp fc (PRef fc (dec n))
587 (map (pexp . (PRef fc)) (map fst ps))
589 | n `nselem` ns = PApp fc (PInferRef fc (dec n))
590 (map (pexp . (PRef fc)) (map fst ps))
591 en (PApp fc f as) = PApp fc (en f) (map (fmap en) as)
592 en (PCase fc c os) = PCase fc (en c) (map (pmap en) os)
596 nselem x (y : xs) | nseq x y = True
597 | otherwise = nselem x xs
599 nseq x y = nsroot x == nsroot y
601expandParamsD :: Bool -> -- True = RHS only
603 (Name -> Name) -> [(Name, PTerm)] -> [Name] -> PDecl -> PDecl
604expandParamsD rhsonly ist dec ps ns (PTy doc syn fc o n ty)
605 = if n `elem` ns && (not rhsonly)
606 then -- trace (show (n, expandParams dec ps ns ty)) $
607 PTy doc syn fc o (dec n) (piBind ps (expandParams dec ps ns [] ty))
608 else --trace (show (n, expandParams dec ps ns ty)) $
609 PTy doc syn fc o n (expandParams dec ps ns [] ty)
610expandParamsD rhsonly ist dec ps ns (PPostulate doc syn fc o n ty)
611 = if n `elem` ns && (not rhsonly)
612 then -- trace (show (n, expandParams dec ps ns ty)) $
613 PPostulate doc syn fc o (dec n) (piBind ps
614 (expandParams dec ps ns [] ty))
615 else --trace (show (n, expandParams dec ps ns ty)) $
616 PPostulate doc syn fc o n (expandParams dec ps ns [] ty)
617expandParamsD rhsonly ist dec ps ns (PClauses fc opts n cs)
618 = let n' = if n `elem` ns then dec n else n in
619 PClauses fc opts n' (map expandParamsC cs)
621 expandParamsC (PClause fc n lhs ws rhs ds)
622 = let -- ps' = updateps True (namesIn ist rhs) (zip ps [0..])
623 ps'' = updateps False (namesIn [] ist lhs) (zip ps [0..])
624 lhs' = if rhsonly then lhs else (expandParams dec ps'' ns [] lhs)
625 n' = if n `elem` ns then dec n else n in
627 (map (expandParams dec ps'' ns []) ws)
628 (expandParams dec ps'' ns [] rhs)
629 (map (expandParamsD True ist dec ps'' ns) ds)
630 expandParamsC (PWith fc n lhs ws wval ds)
631 = let -- ps' = updateps True (namesIn ist wval) (zip ps [0..])
632 ps'' = updateps False (namesIn [] ist lhs) (zip ps [0..])
633 lhs' = if rhsonly then lhs else (expandParams dec ps'' ns [] lhs)
634 n' = if n `elem` ns then dec n else n in
636 (map (expandParams dec ps'' ns []) ws)
637 (expandParams dec ps'' ns [] wval)
638 (map (expandParamsD rhsonly ist dec ps'' ns) ds)
639 updateps yn nm [] = []
640 updateps yn nm (((a, t), i):as)
641 | (a `elem` nm) == yn = (a, t) : updateps yn nm as
642 | otherwise = (MN i (show n ++ "_u"), t) : updateps yn nm as
643expandParamsD rhs ist dec ps ns (PData doc syn fc co pd)
644 = PData doc syn fc co (expandPData pd)
646 -- just do the type decl, leave constructors alone (parameters will be
648 expandPData (PDatadecl n ty cons)
650 then PDatadecl (dec n) (piBind ps (expandParams dec ps ns [] ty))
652 else PDatadecl n (expandParams dec ps ns [] ty) (map econ cons)
654 = (doc, dec n, piBindp expl ps (expandParams dec ps ns [] t), fc)
655expandParamsD rhs ist dec ps ns (PParams f params pds)
656 = PParams f (ps ++ map (mapsnd (expandParams dec ps ns [])) params)
657 (map (expandParamsD True ist dec ps ns) pds)
658-- (map (expandParamsD ist dec ps ns) pds)
659expandParamsD rhs ist dec ps ns (PMutual f pds)
660 = PMutual f (map (expandParamsD rhs ist dec ps ns) pds)
661expandParamsD rhs ist dec ps ns (PClass doc info f cs n params decls)
663 (map (expandParams dec ps ns []) cs)
665 (map (mapsnd (expandParams dec ps ns [])) params)
666 (map (expandParamsD rhs ist dec ps ns) decls)
667expandParamsD rhs ist dec ps ns (PInstance info f cs n params ty cn decls)
669 (map (expandParams dec ps ns []) cs)
671 (map (expandParams dec ps ns []) params)
672 (expandParams dec ps ns [] ty)
674 (map (expandParamsD rhs ist dec ps ns) decls)
675expandParamsD rhs ist dec ps ns d = d
677mapsnd f (x, t) = (x, f t)
679-- Calculate a priority for a type, for deciding elaboration order
680-- * if it's just a type variable or concrete type, do it early (0)
681-- * if there's only type variables and injective constructors, do it next (1)
682-- * if there's a function type, next (2)
683-- * finally, everything else (3)
685getPriority :: IState -> PTerm -> Int
686getPriority i tm = 1 -- pri tm
689 case lookupP n (tt_ctxt i) of
690 ((P (DCon _ _) _ _):_) -> 1
691 ((P (TCon _ _) _ _):_) -> 1
693 [] -> 0 -- must be locally bound, if it's not an error...
694 pri (PPi _ _ x y) = max 5 (max (pri x) (pri y))
698 pri (PEq _ l r) = max 1 (max (pri l) (pri r))
699 pri (PRewrite _ l r) = max 1 (max (pri l) (pri r))
700 pri (PApp _ f as) = max 1 (max (pri f) (foldr max 0 (map (pri.getTm) as)))
701 pri (PCase _ f as) = max 1 (max (pri f) (foldr max 0 (map (pri.snd) as)))
702 pri (PTyped l r) = pri l
703 pri (PPair _ l r) = max 1 (max (pri l) (pri r))
704 pri (PDPair _ l t r) = max 1 (max (pri l) (max (pri t) (pri r)))
705 pri (PAlternative a as) = maximum (map pri as)
706 pri (PConstant _) = 0
710addStatics :: Name -> Term -> PTerm -> Idris ()
712 do let (statics, dynamics) = initStatics tm ptm
713 let stnames = nub $ concatMap freeNames (map snd statics)
714 let dnames = nub $ concatMap freeNames (map snd dynamics)
715 when (not (null statics)) $
716 logLvl 7 $ show n ++ " " ++ show statics ++ "\n" ++ show dynamics
717 ++ "\n" ++ show stnames ++ "\n" ++ show dnames
718 let statics' = nub $ map fst statics ++
719 filter (\x -> not (elem x dnames)) stnames
720 let stpos = staticList statics' tm
722 putIState $ i { idris_statics = addDef n stpos (idris_statics i) }
725 initStatics (Bind n (Pi ty) sc) (PPi p _ _ s)
726 = let (static, dynamic) = initStatics (instantiate (P Bound n ty) sc) s in
727 if pstatic p == Static then ((n, ty) : static, dynamic)
728 else (static, (n, ty) : dynamic)
729 initStatics t pt = ([], [])
731 staticList sts (Bind n (Pi _) sc) = (n `elem` sts) : staticList sts sc
734-- Dealing with implicit arguments
736-- Add implicit Pi bindings for any names in the term which appear in an
739-- This has become a right mess already. Better redo it some time...
741implicit :: SyntaxInfo -> Name -> PTerm -> Idris PTerm
742implicit syn n ptm = implicit' syn [] n ptm
744implicit' :: SyntaxInfo -> [Name] -> Name -> PTerm -> Idris PTerm
745implicit' syn ignore n ptm
747 let (tm', impdata) = implicitise syn ignore i ptm
748-- let (tm'', spos) = findStatics i tm'
749 putIState $ i { idris_implicits = addDef n impdata (idris_implicits i) }
751 logLvl 5 ("Implicit " ++ show n ++ " " ++ show impdata)
753-- putIState $ i { idris_statics = addDef n spos (idris_statics i) }
756implicitise :: SyntaxInfo -> [Name] -> IState -> PTerm -> (PTerm, [PArg])
757implicitise syn ignore ist tm
758 = let (declimps, ns') = execState (imps True [] tm) ([], [])
759 ns = filter (\n -> implicitable n || elem n (map fst uvars)) $
760 ns' \\ (map fst pvars ++ no_imp syn ++ ignore) in
762 then (tm, reverse declimps)
763 else implicitise syn ignore ist (pibind uvars ns tm)
766 pvars = syn_params syn
768 dropAll (x:xs) ys | x `elem` ys = dropAll xs ys
769 | otherwise = x : dropAll xs ys
772 imps top env (PApp _ f as)
773 = do (decls, ns) <- get
774 let isn = concatMap (namesIn uvars ist) (map getTm as)
775 put (decls, nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
776 imps top env (PPi (Imp l _ doc) n ty sc)
777 = do let isn = nub (namesIn uvars ist ty) `dropAll` [n]
779 put (PImp (getPriority ist ty) l n ty doc : decls,
780 nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
782 imps top env (PPi (Exp l _ doc) n ty sc)
783 = do let isn = nub (namesIn uvars ist ty ++ case sc of
784 (PRef _ x) -> namesIn uvars ist sc `dropAll` [n]
786 (decls, ns) <- get -- ignore decls in HO types
787 put (PExp (getPriority ist ty) l ty doc : decls,
788 nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
790 imps top env (PPi (Constraint l _ doc) n ty sc)
791 = do let isn = nub (namesIn uvars ist ty ++ case sc of
792 (PRef _ x) -> namesIn uvars ist sc `dropAll` [n]
794 (decls, ns) <- get -- ignore decls in HO types
795 put (PConstraint 10 l ty doc : decls,
796 nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
798 imps top env (PPi (TacImp l _ scr doc) n ty sc)
799 = do let isn = nub (namesIn uvars ist ty ++ case sc of
800 (PRef _ x) -> namesIn uvars ist sc `dropAll` [n]
802 (decls, ns) <- get -- ignore decls in HO types
803 put (PTacImplicit 10 l n scr ty doc : decls,
804 nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
806 imps top env (PEq _ l r)
807 = do (decls, ns) <- get
808 let isn = namesIn uvars ist l ++ namesIn uvars ist r
809 put (decls, nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
810 imps top env (PRewrite _ l r)
811 = do (decls, ns) <- get
812 let isn = namesIn uvars ist l ++ namesIn uvars ist r
813 put (decls, nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
814 imps top env (PTyped l r)
816 imps top env (PPair _ l r)
817 = do (decls, ns) <- get
818 let isn = namesIn uvars ist l ++ namesIn uvars ist r
819 put (decls, nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
820 imps top env (PDPair _ (PRef _ n) t r)
821 = do (decls, ns) <- get
822 let isn = nub (namesIn uvars ist t ++ namesIn uvars ist r) \\ [n]
823 put (decls, nub (ns ++ (isn \\ (env ++ map fst (getImps decls)))))
824 imps top env (PDPair _ l t r)
825 = do (decls, ns) <- get
826 let isn = namesIn uvars ist l ++ namesIn uvars ist t ++
828 put (decls, nub (ns ++ (isn \\ (env ++ map fst (getImps decls)))))
829 imps top env (PAlternative a as)
830 = do (decls, ns) <- get
831 let isn = concatMap (namesIn uvars ist) as
832 put (decls, nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
833 imps top env (PLam n ty sc)
834 = do imps False env ty
835 imps False (n:env) sc
836 imps top env (PHidden tm) = imps False env tm
837 imps top env _ = return ()
839 pibind using [] sc = sc
840 pibind using (n:ns) sc
841 = case lookup n using of
842 Just ty -> PPi (Imp False Dynamic "") n ty (pibind using ns sc)
843 Nothing -> PPi (Imp False Dynamic "") n Placeholder
846-- Add implicit arguments in function calls
847addImplPat :: IState -> PTerm -> PTerm
848addImplPat = addImpl' True [] []
850addImplBound :: IState -> [Name] -> PTerm -> PTerm
851addImplBound ist ns = addImpl' False ns [] ist
853addImplBoundInf :: IState -> [Name] -> [Name] -> PTerm -> PTerm
854addImplBoundInf ist ns inf = addImpl' False ns inf ist
856addImpl :: IState -> PTerm -> PTerm
857addImpl = addImpl' False [] []
859-- TODO: in patterns, don't add implicits to function names guarded by constructors
860-- and *not* inside a PHidden
862addImpl' :: Bool -> [Name] -> [Name] -> IState -> PTerm -> PTerm
863addImpl' inpat env infns ist ptm = ai (zip env (repeat Nothing)) ptm
866 | f `elem` infns = PInferRef fc f
867 | not (f `elem` map fst env) = handleErr $ aiFn inpat inpat ist fc f []
868 ai env (PHidden (PRef fc f))
869 | not (f `elem` map fst env) = handleErr $ aiFn inpat False ist fc f []
870 ai env (PEq fc l r) = let l' = ai env l
873 ai env (PRewrite fc l r) = let l' = ai env l
876 ai env (PTyped l r) = let l' = ai env l
879 ai env (PPair fc l r) = let l' = ai env l
882 ai env (PDPair fc l t r) = let l' = ai env l
886 ai env (PAlternative a as) = let as' = map (ai env) as in
888 ai env (PApp fc (PInferRef _ f) as)
889 = let as' = map (fmap (ai env)) as in
890 PApp fc (PInferRef fc f) as'
891 ai env (PApp fc ftm@(PRef _ f) as)
892 | f `elem` infns = ai env (PApp fc (PInferRef fc f) as)
893 | not (f `elem` map fst env)
894 = let as' = map (fmap (ai env)) as in
895 handleErr $ aiFn inpat False ist fc f as'
896 | Just (Just ty) <- lookup f env
897 = let as' = map (fmap (ai env)) as
898 arity = getPArity ty in
899 mkPApp fc arity ftm as'
900 ai env (PApp fc f as) = let f' = ai env f
901 as' = map (fmap (ai env)) as in
903 ai env (PCase fc c os) = let c' = ai env c
904 os' = map (pmap (ai env)) os in
906 ai env (PLam n ty sc) = let ty' = ai env ty
907 sc' = ai ((n, Just ty):env) sc in
909 ai env (PLet n ty val sc)
910 = let ty' = ai env ty
912 sc' = ai ((n, Just ty):env) sc in
914 ai env (PPi p n ty sc) = let ty' = ai env ty
915 sc' = ai ((n, Just ty):env) sc in
917 ai env (PHidden tm) = PHidden (ai env tm)
918 ai env (PProof ts) = PProof (map (fmap (ai env)) ts)
919 ai env (PTactics ts) = PTactics (map (fmap (ai env)) ts)
922 handleErr (Left err) = PElabError err
923 handleErr (Right x) = x
925-- if in a pattern, and there are no arguments, and there's no possible
926-- names with zero explicit arguments, don't add implicits.
928aiFn :: Bool -> Bool -> IState -> FC -> Name -> [PArg] -> Either Err PTerm
929aiFn inpat True ist fc f []
930 = case lookupDef f (tt_ctxt ist) of
931 [] -> Right $ PPatvar fc f
932 alts -> let ialts = lookupCtxt f (idris_implicits ist) in
933 -- trace (show f ++ " " ++ show (fc, any (all imp) ialts, ialts, any constructor alts)) $
934 if (not (vname f) || tcname f
935 || any constructor alts || any allImp ialts)
936 then aiFn inpat False ist fc f [] -- use it as a constructor
937 else Right $ PPatvar fc f
938 where imp (PExp _ _ _ _) = False
941 allImp xs = all imp xs
942 constructor (TyDecl (DCon _ _) _) = True
943 constructor _ = False
945 vname (UN n) = True -- non qualified
948aiFn inpat expat ist fc f as
949 | f `elem` primNames = Right $ PApp fc (PRef fc f) as
950aiFn inpat expat ist fc f as
951 -- This is where namespaces get resolved by adding PAlternative
952 = case lookupCtxtName f (idris_implicits ist) of
953 [(f',ns)] -> Right $ mkPApp fc (length ns) (PRef fc f') (insertImpl ns as)
954 [] -> if f `elem` idris_metavars ist
955 then Right $ PApp fc (PRef fc f) as
956 else Right $ mkPApp fc (length as) (PRef fc f) as
959 map (\(f', ns) -> mkPApp fc (length ns) (PRef fc f')
960 (insertImpl ns as)) alts
962 insertImpl :: [PArg] -> [PArg] -> [PArg]
963 insertImpl (PExp p l ty _ : ps) (PExp _ _ tm d : given) =
964 PExp p l tm d : insertImpl ps given
965 insertImpl (PConstraint p l ty _ : ps) (PConstraint _ _ tm d : given) =
966 PConstraint p l tm d : insertImpl ps given
967 insertImpl (PConstraint p l ty d : ps) given =
968 PConstraint p l (PResolveTC fc) d : insertImpl ps given
969 insertImpl (PImp p l n ty d : ps) given =
970 case find n given [] of
971 Just (tm, given') -> PImp p l n tm "" : insertImpl ps given'
972 Nothing -> PImp p l n Placeholder "" : insertImpl ps given
973 insertImpl (PTacImplicit p l n sc ty d : ps) given =
974 case find n given [] of
975 Just (tm, given') -> PTacImplicit p l n sc tm "" : insertImpl ps given'
977 then PTacImplicit p l n sc Placeholder "" : insertImpl ps given
978 else PTacImplicit p l n sc sc "" : insertImpl ps given
979 insertImpl expected [] = []
980 insertImpl _ given = given
982 find n [] acc = Nothing
983 find n (PImp _ _ n' t _ : gs) acc
984 | n == n' = Just (t, reverse acc ++ gs)
985 find n (PTacImplicit _ _ n' _ t _ : gs) acc
986 | n == n' = Just (t, reverse acc ++ gs)
987 find n (g : gs) acc = find n gs (g : acc)
989-- replace non-linear occurrences with _
990-- ASSUMPTION: This is called before adding 'alternatives' because otherwise
991-- it is hard to get right!
993stripLinear :: IState -> PTerm -> PTerm
994stripLinear i tm = evalState (sl tm) [] where
995 sl :: PTerm -> State [Name] PTerm
997 | (_:_) <- lookupTy f (tt_ctxt i)
999 | otherwise = do ns <- get
1001 then return Placeholder
1002 else do put (f : ns)
1007 then return Placeholder
1008 else do put (f : ns)
1009 return (PPatvar fc f)
1010 sl (PApp fc fn args) = do fn' <- sl fn
1011 args' <- mapM slA args
1012 return $ PApp fc fn' args'
1013 where slA (PImp p l n t d) = do t' <- sl t
1014 return $ PImp p l n t' d
1015 slA (PExp p l t d) = do t' <- sl t
1016 return $ PExp p l t' d
1017 slA (PConstraint p l t d)
1019 return $ PConstraint p l t' d
1020 slA (PTacImplicit p l n sc t d)
1022 return $ PTacImplicit p l n sc t' d
1026mkPApp fc a f as = let rest = drop a as in
1027 appRest fc (PApp fc f (take a as)) rest
1030 appRest fc f (a : as) = appRest fc (PApp fc f [a]) as
1032-- Find 'static' argument positions
1033-- (the declared ones, plus any names in argument position in the declared
1035-- FIXME: It's possible that this really has to happen after elaboration
1037findStatics :: IState -> PTerm -> (PTerm, [Bool])
1038findStatics ist tm = trace (showImp True tm) $
1039 let (ns, ss) = fs tm in
1040 runState (pos ns ss tm) []
1041 where fs (PPi p n t sc)
1042 | Static <- pstatic p
1043 = let (ns, ss) = fs sc in
1044 (namesIn [] ist t : ns, n : ss)
1045 | otherwise = let (ns, ss) = fs sc in
1049 inOne n ns = length (filter id (map (elem n) ns)) == 1
1051 pos ns ss (PPi p n t sc)
1052 | elem n ss = do sc' <- pos ns ss sc
1055 return (PPi (p { pstatic = Static }) n t sc')
1056 | otherwise = do sc' <- pos ns ss sc
1059 return (PPi p n t sc')
1060 pos ns ss t = return t
1062-- Debugging/logging stuff
1064dumpDecls :: [PDecl] -> String
1066dumpDecls (d:ds) = dumpDecl d ++ "\n" ++ dumpDecls ds
1068dumpDecl (PFix _ f ops) = show f ++ " " ++ showSep ", " ops
1069dumpDecl (PTy _ _ _ _ n t) = "tydecl " ++ show n ++ " : " ++ showImp True t
1070dumpDecl (PClauses _ _ n cs) = "pat " ++ show n ++ "\t" ++ showSep "\n\t" (map (showCImp True) cs)
1071dumpDecl (PData _ _ _ _ d) = showDImp True d
1072dumpDecl (PParams _ ns ps) = "params {" ++ show ns ++ "\n" ++ dumpDecls ps ++ "}\n"
1073dumpDecl (PNamespace n ps) = "namespace {" ++ n ++ "\n" ++ dumpDecls ps ++ "}\n"
1074dumpDecl (PSyntax _ syn) = "syntax " ++ show syn
1075dumpDecl (PClass _ _ _ cs n ps ds)
1076 = "class " ++ show cs ++ " " ++ show n ++ " " ++ show ps ++ "\n" ++ dumpDecls ds
1077dumpDecl (PInstance _ _ cs n _ t _ ds)
1078 = "instance " ++ show cs ++ " " ++ show n ++ " " ++ show t ++ "\n" ++ dumpDecls ds
1080-- dumpDecl (PImport i) = "import " ++ i
1082-- for 6.12/7 compatibility
1083data EitherErr a b = LeftErr a | RightOK b
1085instance Monad (EitherErr a) where
1088 (LeftErr e) >>= k = LeftErr e
1089 RightOK v >>= k = k v
1091toEither (LeftErr e) = Left e
1092toEither (RightOK ho) = Right ho
1094-- syntactic match of a against b, returning pair of variables in a
1095-- and what they match. Returns the pair that failed if not a match.
1097matchClause :: IState -> PTerm -> PTerm -> Either (PTerm, PTerm) [(Name, PTerm)]
1098matchClause = matchClause' False
1100matchClause' :: Bool -> IState -> PTerm -> PTerm -> Either (PTerm, PTerm) [(Name, PTerm)]
1101matchClause' names i x y = checkRpts $ match (fullApp x) (fullApp y) where
1102 matchArg x y = match (fullApp (getTm x)) (fullApp (getTm y))
1104 fullApp (PApp _ (PApp fc f args) xs) = fullApp (PApp fc f (args ++ xs))
1107 match' x y = match (fullApp x) (fullApp y)
1108 match (PApp _ (PRef _ (NS (UN "fromInteger") ["builtins"])) [_,_,x]) x'
1109 | PConstant (I _) <- getTm x = match (getTm x) x'
1110 match x' (PApp _ (PRef _ (NS (UN "fromInteger") ["builtins"])) [_,_,x])
1111 | PConstant (I _) <- getTm x = match (getTm x) x'
1112 match (PApp _ (PRef _ (UN "lazy")) [_,x]) x' = match (getTm x) x'
1113 match x (PApp _ (PRef _ (UN "lazy")) [_,x']) = match x (getTm x')
1114 match (PApp _ f args) (PApp _ f' args')
1115 | length args == length args'
1116 = do mf <- match' f f'
1117 ms <- zipWithM matchArg args args'
1118 return (mf ++ concat ms)
1119-- match (PRef _ n) (PRef _ n') | n == n' = return []
1120-- | otherwise = Nothing
1121 match (PRef f n) (PApp _ x []) = match (PRef f n) x
1122 match (PPatvar f n) xr = match (PRef f n) xr
1123 match xr (PPatvar f n) = match xr (PRef f n)
1124 match (PApp _ x []) (PRef f n) = match x (PRef f n)
1125 match (PRef _ n) tm@(PRef _ n')
1126 | n == n' && not names &&
1127 (not (isConName n (tt_ctxt i)) || tm == Placeholder)
1129 | n == n' = return []
1131 | not names && (not (isConName n (tt_ctxt i)) || tm == Placeholder)
1133 match (PEq _ l r) (PEq _ l' r') = do ml <- match' l l'
1136 match (PRewrite _ l r) (PRewrite _ l' r')
1137 = do ml <- match' l l'
1140 match (PTyped l r) (PTyped l' r') = do ml <- match l l'
1143 match (PTyped l r) x = match l x
1144 match x (PTyped l r) = match x l
1145 match (PPair _ l r) (PPair _ l' r') = do ml <- match' l l'
1148 match (PDPair _ l t r) (PDPair _ l' t' r') = do ml <- match' l l'
1151 return (ml ++ mt ++ mr)
1152 match (PAlternative a as) (PAlternative a' as')
1153 = do ms <- zipWithM match' as as'
1155 match a@(PAlternative _ as) b
1156 = do let ms = zipWith match' as (repeat b)
1157 case (rights (map toEither ms)) of
1160 match (PCase _ _ _) _ = return [] -- lifted out
1161 match (PMetavar _) _ = return [] -- modified
1162 match (PInferRef _ _) _ = return [] -- modified
1163 match (PQuote _) _ = return []
1164 match (PProof _) _ = return []
1165 match (PTactics _) _ = return []
1166 match (PRefl _ _) (PRefl _ _) = return []
1167 match (PResolveTC _) (PResolveTC _) = return []
1168 match (PTrue _) (PTrue _) = return []
1169 match (PFalse _) (PFalse _) = return []
1170 match (PReturn _) (PReturn _) = return []
1171 match (PPi _ _ t s) (PPi _ _ t' s') = do mt <- match' t t'
1174 match (PLam _ t s) (PLam _ t' s') = do mt <- match' t t'
1177 match (PLet _ t ty s) (PLet _ t' ty' s') = do mt <- match' t t'
1178 mty <- match' ty ty'
1180 return (mt ++ mty ++ ms)
1181 match (PHidden x) (PHidden y) = match' x y
1182 match Placeholder _ = return []
1183 match _ Placeholder = return []
1184 match (PResolveTC _) _ = return []
1185 match a b | a == b = return []
1186 | otherwise = LeftErr (a, b)
1188 checkRpts (RightOK ms) = check ms where
1190 | Just t' <- lookup n xs = if t/=t' && t/=Placeholder && t'/=Placeholder
1193 check (_:xs) = check xs
1195 checkRpts (LeftErr x) = Left x
1197substMatches :: [(Name, PTerm)] -> PTerm -> PTerm
1198substMatches ms = substMatchesShadow ms []
1200substMatchesShadow :: [(Name, PTerm)] -> [Name] -> PTerm -> PTerm
1201substMatchesShadow [] shs t = t
1202substMatchesShadow ((n,tm):ns) shs t
1203 = substMatchShadow n shs tm (substMatchesShadow ns shs t)
1205substMatch :: Name -> PTerm -> PTerm -> PTerm
1206substMatch n = substMatchShadow n []
1208substMatchShadow :: Name -> [Name] -> PTerm -> PTerm -> PTerm
1209substMatchShadow n shs tm t = sm shs t where
1210 sm xs (PRef _ n') | n == n' = tm
1211 sm xs (PLam x t sc) = PLam x (sm xs t) (sm xs sc)
1212 sm xs (PPi p x t sc)
1214 = let x' = nextName x in
1215 PPi p x' (sm (x':xs) (substMatch x (PRef (FC "" 0) x') t))
1216 (sm (x':xs) (substMatch x (PRef (FC "" 0) x') sc))
1217 | otherwise = PPi p x (sm xs t) (sm (x : xs) sc)
1218 sm xs (PApp f x as) = PApp f (sm xs x) (map (fmap (sm xs)) as)
1219 sm xs (PCase f x as) = PCase f (sm xs x) (map (pmap (sm xs)) as)
1220 sm xs (PEq f x y) = PEq f (sm xs x) (sm xs y)
1221 sm xs (PRewrite f x y) = PRewrite f (sm xs x) (sm xs y)
1222 sm xs (PTyped x y) = PTyped (sm xs x) (sm xs y)
1223 sm xs (PPair f x y) = PPair f (sm xs x) (sm xs y)
1224 sm xs (PDPair f x t y) = PDPair f (sm xs x) (sm xs t) (sm xs y)
1225 sm xs (PAlternative a as) = PAlternative a (map (sm xs) as)
1226 sm xs (PHidden x) = PHidden (sm xs x)
1229shadow :: Name -> Name -> PTerm -> PTerm
1230shadow n n' t = sm t where
1231 sm (PRef fc x) | n == x = PRef fc n'
1232 sm (PLam x t sc) = PLam x (sm t) (sm sc)
1233 sm (PPi p x t sc) = PPi p x (sm t) (sm sc)
1234 sm (PApp f x as) = PApp f (sm x) (map (fmap sm) as)
1235 sm (PCase f x as) = PCase f (sm x) (map (pmap sm) as)
1236 sm (PEq f x y) = PEq f (sm x) (sm y)
1237 sm (PRewrite f x y) = PRewrite f (sm x) (sm y)
1238 sm (PTyped x y) = PTyped (sm x) (sm y)
1239 sm (PPair f x y) = PPair f (sm x) (sm y)
1240 sm (PDPair f x t y) = PDPair f (sm x) (sm t) (sm y)
1241 sm (PAlternative a as) = PAlternative a (map sm as)
1242 sm (PHidden x) = PHidden (sm x)
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