Skip to content

Instantly share code, notes, and snippets.

@jpm61704
Created April 21, 2020 05:13
Show Gist options
  • Save jpm61704/b2725b6535c5e23babd142c558fd7d5b to your computer and use it in GitHub Desktop.
Save jpm61704/b2725b6535c5e23babd142c558fd7d5b to your computer and use it in GitHub Desktop.
module Search where
import Agda.Syntax.Parser
-- import Agda.Syntax.Abstract as Abstract
import Agda.Syntax.Concrete as Concrete
-- import Agda.Syntax.Translation.ConcreteToAbstract
import Agda.Syntax.Scope.Monad
import Agda.Utils.FileName
import Data.Text.Lazy as T
import Agda.Utils.Pretty
{-
Extracting Definitions From a Library File
1. Open File and getContents
2. Parse the module
-}
testFile :: AbsolutePath
testFile = mkAbsolute "/home/jpm61704/Documents/Research/ProgramSearch/res/library.agda"
parseModule :: AbsolutePath -> PM Module
parseModule path = do f <- readFilePM path
fmap fst $ parseFile moduleParser path (T.unpack f)
withModule :: AbsolutePath -> (Module -> a) -> PM a
withModule path f = do mod <- parseModule path
return (f mod)
allTypeSigs :: Module -> [ Declaration ]
allTypeSigs (ps, ds) = Prelude.filter isTypeSig ds
isTypeSig :: Declaration -> Bool
isTypeSig (TypeSig _ _ _ _) = True
isTypeSig _ = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment