Is it possible to use Agda as a library?

浪尽此生 提交于 2019-12-02 01:29:01

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!