2module Idris.Directives(directiveAction) where
7import Idris.Output (sendHighlighting)
9import Idris.Core.Evaluate
12import Util.DynamicLinker
14-- | Run the action corresponding to a directive
15directiveAction :: Directive -> Idris ()
16directiveAction (DLib cgn lib) = do addLib cgn lib
17 addIBC (IBCLib cgn lib)
19directiveAction (DLink cgn obj) = do dirs <- allImportDirs
20 o <- runIO $ findInPath dirs obj
21 addIBC (IBCObj cgn obj) -- just name, search on loading ibc
24directiveAction (DFlag cgn flag) = do addIBC (IBCCGFlag cgn flag)
27directiveAction (DInclude cgn hdr) = do addHdr cgn hdr
28 addIBC (IBCHeader cgn hdr)
30directiveAction (DHide n) = do setAccessibility n Hidden
31 addIBC (IBCAccess n Hidden)
33directiveAction (DFreeze n) = do setAccessibility n Frozen
34 addIBC (IBCAccess n Frozen)
36directiveAction (DAccess acc) = do updateIState (\i -> i { default_access = acc })
38directiveAction (DDefault tot) = do updateIState (\i -> i { default_total = tot })
40directiveAction (DLogging lvl) = setLogLevel (fromInteger lvl)
42directiveAction (DDynamicLibs libs) = do added <- addDyLib libs
44 Left lib -> addIBC (IBCDyLib (lib_name lib))
45 Right msg -> fail $ msg
47directiveAction (DNameHint ty tyFC ns) = do ty' <- disambiguate ty
48 mapM_ (addNameHint ty' . fst) ns
49 mapM_ (\n -> addIBC (IBCNameHint (ty', fst n))) ns
51 [(tyFC, AnnName ty' Nothing Nothing Nothing)] ++
52 map (\(n, fc) -> (fc, AnnBoundName n False)) ns
54directiveAction (DErrorHandlers fn nfc arg afc ns) =
55 do fn' <- disambiguate fn
56 ns' <- mapM (\(n, fc) -> do n' <- disambiguate n
58 addFunctionErrorHandlers fn' arg (map fst ns')
60 IBCFunctionErrorHandler fn' arg . fst) ns'
62 [(nfc, AnnName fn' Nothing Nothing Nothing),
63 (afc, AnnBoundName arg False)] ++
64 map (\(n, fc) -> (fc, AnnName n Nothing Nothing Nothing)) ns'
66directiveAction (DLanguage ext) = addLangExt ext
68directiveAction (DUsed fc fn arg) = addUsedName fc fn arg
70disambiguate :: Name -> Idris Name
71disambiguate n = do i <- getIState
72 case lookupCtxtName n (idris_implicits i) of
73 [(n', _)] -> return n'
74 [] -> throwError (NoSuchVariable n)
75 more -> throwError (CantResolveAlts (map fst more))
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