问题
Instead of using Agda on a filesystem (with EMACS, terminal, etc.), is it possible to use it directly from Haskell, as a library? For example:
-- UsingAgda.hs
import Agda
-- Prints the type of a term on some Agda code
main :: IO ()
main = typeOf "true" agdaCode where
agdaCode :: String
agdaCode = unlines
["module Hello where "
," "
,"data Bool : Set where"
," true : Bool "
," false : Bool "]
The code above would output Bool
, because true : Bool
on that Agda code.
回答1:
Yes, it is possible. Agda was designed as a Haskell library plus a main module.
You can see a couple of small examples here. As a bigger example, I wrote Apia (shameless plug), which uses Agda as a library.
Please keep in mind that the current Agda description says:
Note that the Agda package does not follow the package versioning policy, because it is not intended to be used by third-party packages.
Of course, it could change.
来源:https://stackoverflow.com/questions/49330226/is-it-possible-to-use-agda-as-a-library