2015-01-21 05:10:45 +00:00
|
|
|
|
require "language/haskell"
|
|
|
|
|
|
|
|
|
|
class Agda < Formula
|
|
|
|
|
include Language::Haskell::Cabal
|
2015-12-19 20:58:42 +00:00
|
|
|
|
|
2015-05-19 00:00:59 +00:00
|
|
|
|
desc "Dependently typed functional programming language"
|
2015-01-21 05:10:45 +00:00
|
|
|
|
homepage "http://wiki.portal.chalmers.se/agda/"
|
2015-11-01 19:22:02 +00:00
|
|
|
|
|
|
|
|
|
stable do
|
2016-11-25 17:41:24 +00:00
|
|
|
|
url "https://hackage.haskell.org/package/Agda-2.5.1.2/Agda-2.5.1.2.tar.gz"
|
|
|
|
|
sha256 "fb272bd6f7d532320c669b96faa85088b37bae02d906e9a9f764bc8e8639fb5e"
|
2015-12-19 20:58:42 +00:00
|
|
|
|
|
|
|
|
|
resource "stdlib" do
|
2016-04-18 23:41:23 +00:00
|
|
|
|
url "https://github.com/agda/agda-stdlib/archive/v0.12.tar.gz"
|
|
|
|
|
sha256 "2fddbc6d08e74c6205075704f40c550fc40137dee44e6b22b2e08ddee1410e87"
|
2016-02-22 15:23:51 +00:00
|
|
|
|
end
|
2015-11-01 19:22:02 +00:00
|
|
|
|
end
|
2015-01-21 05:10:45 +00:00
|
|
|
|
|
2015-01-23 05:10:47 +00:00
|
|
|
|
bottle do
|
2016-11-25 20:19:23 +00:00
|
|
|
|
sha256 "5691b10122b6b0c77965dd7ff66be62e7dc297f85431a768d5e9d21250815dfa" => :sierra
|
|
|
|
|
sha256 "201487d5d08f370884b741e182ac50fbbc2194a8eb7cb925e2a40094a2ed0cf1" => :el_capitan
|
|
|
|
|
sha256 "6c1a67467b50d108dcd7cd45579fdab225169671318b882b957f8e65818127f9" => :yosemite
|
2015-01-23 05:10:47 +00:00
|
|
|
|
end
|
|
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
|
head do
|
2015-12-19 20:58:42 +00:00
|
|
|
|
url "https://github.com/agda/agda.git"
|
|
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
|
resource "stdlib" do
|
2015-12-19 20:58:42 +00:00
|
|
|
|
url "https://github.com/agda/agda-stdlib.git"
|
2015-10-25 13:46:32 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2016-04-18 23:41:23 +00:00
|
|
|
|
deprecated_option "without-malonzo" => "without-ghc"
|
|
|
|
|
|
2015-02-09 20:46:31 +00:00
|
|
|
|
option "without-stdlib", "Don't install the Agda standard library"
|
2016-04-18 23:41:23 +00:00
|
|
|
|
option "without-ghc", "Disable the GHC backend"
|
2015-01-21 05:10:45 +00:00
|
|
|
|
|
2016-04-18 23:41:23 +00:00
|
|
|
|
depends_on "ghc" => :recommended
|
|
|
|
|
if build.with? "ghc"
|
|
|
|
|
depends_on "cabal-install"
|
2015-10-25 13:46:32 +00:00
|
|
|
|
else
|
|
|
|
|
depends_on "ghc" => :build
|
2016-04-18 23:41:23 +00:00
|
|
|
|
depends_on "cabal-install" => :build
|
2015-10-25 13:46:32 +00:00
|
|
|
|
end
|
2015-04-30 05:48:53 +00:00
|
|
|
|
|
2016-09-24 15:45:48 +00:00
|
|
|
|
depends_on :emacs => ["23.4", :recommended]
|
2015-02-09 20:46:31 +00:00
|
|
|
|
|
2015-01-21 05:10:45 +00:00
|
|
|
|
def install
|
2015-02-09 20:46:31 +00:00
|
|
|
|
# install Agda core
|
2016-09-24 15:45:48 +00:00
|
|
|
|
install_cabal_package :using => ["alex", "happy", "cpphs"]
|
2015-02-09 20:46:31 +00:00
|
|
|
|
|
|
|
|
|
if build.with? "stdlib"
|
2015-12-20 13:49:46 +00:00
|
|
|
|
resource("stdlib").stage lib/"agda"
|
2015-02-09 20:46:31 +00:00
|
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
|
# generate the standard library's bytecode
|
2015-12-20 13:49:46 +00:00
|
|
|
|
cd lib/"agda" do
|
2016-09-24 15:45:48 +00:00
|
|
|
|
cabal_sandbox :home => buildpath, :keep_lib => true do
|
2015-02-09 20:46:31 +00:00
|
|
|
|
cabal_install "--only-dependencies"
|
2015-10-25 13:46:32 +00:00
|
|
|
|
cabal_install
|
|
|
|
|
system "GenerateEverything"
|
2015-02-09 20:46:31 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# generate the standard library's documentation and vim highlighting files
|
2015-12-20 13:49:46 +00:00
|
|
|
|
cd lib/"agda" do
|
2015-02-09 20:46:31 +00:00
|
|
|
|
system bin/"agda", "-i", ".", "-i", "src", "--html", "--vim", "README.agda"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
|
# compile the included Emacs mode
|
2015-02-09 20:46:31 +00:00
|
|
|
|
if build.with? "emacs"
|
|
|
|
|
system bin/"agda-mode", "compile"
|
2015-12-05 04:44:46 +00:00
|
|
|
|
elisp.install_symlink Dir["#{share}/*/Agda-#{version}/emacs-mode/*"]
|
2015-02-09 20:46:31 +00:00
|
|
|
|
end
|
2015-01-21 05:10:45 +00:00
|
|
|
|
end
|
|
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
|
def caveats
|
|
|
|
|
s = ""
|
|
|
|
|
|
|
|
|
|
if build.with? "stdlib"
|
|
|
|
|
s += <<-EOS.undent
|
2016-04-18 23:41:23 +00:00
|
|
|
|
To use the Agda standard library by default:
|
|
|
|
|
mkdir -p ~/.agda
|
|
|
|
|
echo #{HOMEBREW_PREFIX}/lib/agda/standard-library.agda-lib >>~/.agda/libraries
|
|
|
|
|
echo standard-library >>~/.agda/defaults
|
2015-10-25 13:46:32 +00:00
|
|
|
|
EOS
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
s
|
|
|
|
|
end
|
|
|
|
|
|
2015-01-21 05:10:45 +00:00
|
|
|
|
test do
|
2016-04-18 23:41:23 +00:00
|
|
|
|
simpletest = testpath/"SimpleTest.agda"
|
|
|
|
|
simpletest.write <<-EOS.undent
|
|
|
|
|
module SimpleTest where
|
|
|
|
|
|
|
|
|
|
data ℕ : Set where
|
|
|
|
|
zero : ℕ
|
|
|
|
|
suc : ℕ → ℕ
|
|
|
|
|
|
|
|
|
|
infixl 6 _+_
|
|
|
|
|
_+_ : ℕ → ℕ → ℕ
|
|
|
|
|
zero + n = n
|
|
|
|
|
suc m + n = suc (m + n)
|
|
|
|
|
|
|
|
|
|
infix 4 _≡_
|
|
|
|
|
data _≡_ {A : Set} (x : A) : A → Set where
|
|
|
|
|
refl : x ≡ x
|
|
|
|
|
|
|
|
|
|
cong : ∀ {A B : Set} (f : A → B) {x y} → x ≡ y → f x ≡ f y
|
|
|
|
|
cong f refl = refl
|
|
|
|
|
|
|
|
|
|
+-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)
|
|
|
|
|
+-assoc zero _ _ = refl
|
|
|
|
|
+-assoc (suc m) n o = cong suc (+-assoc m n o)
|
|
|
|
|
EOS
|
|
|
|
|
|
|
|
|
|
stdlibtest = testpath/"StdlibTest.agda"
|
|
|
|
|
stdlibtest.write <<-EOS.undent
|
|
|
|
|
module StdlibTest where
|
|
|
|
|
|
|
|
|
|
open import Data.Nat
|
|
|
|
|
open import Relation.Binary.PropositionalEquality
|
|
|
|
|
|
|
|
|
|
+-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)
|
|
|
|
|
+-assoc zero _ _ = refl
|
|
|
|
|
+-assoc (suc m) n o = cong suc (+-assoc m n o)
|
|
|
|
|
EOS
|
|
|
|
|
|
|
|
|
|
iotest = testpath/"IOTest.agda"
|
|
|
|
|
iotest.write <<-EOS.undent
|
|
|
|
|
module IOTest where
|
|
|
|
|
|
|
|
|
|
open import Agda.Builtin.IO
|
|
|
|
|
open import Agda.Builtin.Unit
|
|
|
|
|
|
|
|
|
|
postulate
|
|
|
|
|
return : ∀ {A : Set} → A → IO A
|
|
|
|
|
|
|
|
|
|
{-# COMPILED return (\\_ -> return) #-}
|
|
|
|
|
|
|
|
|
|
main : _
|
|
|
|
|
main = return tt
|
|
|
|
|
EOS
|
|
|
|
|
|
|
|
|
|
stdlibiotest = testpath/"StdlibIOTest.agda"
|
|
|
|
|
stdlibiotest.write <<-EOS.undent
|
|
|
|
|
module StdlibIOTest where
|
|
|
|
|
|
|
|
|
|
open import IO
|
|
|
|
|
|
|
|
|
|
main : _
|
|
|
|
|
main = run (putStr "Hello, world!")
|
|
|
|
|
EOS
|
|
|
|
|
|
2015-01-21 05:10:45 +00:00
|
|
|
|
# run Agda's built-in test suite
|
|
|
|
|
system bin/"agda", "--test"
|
|
|
|
|
|
2016-04-18 23:41:23 +00:00
|
|
|
|
# typecheck a simple module
|
|
|
|
|
system bin/"agda", simpletest
|
|
|
|
|
|
|
|
|
|
# typecheck a module that uses the standard library
|
|
|
|
|
if build.with? "stdlib"
|
|
|
|
|
system bin/"agda", "-i", lib/"agda"/"src", stdlibtest
|
2015-10-25 13:46:32 +00:00
|
|
|
|
end
|
2016-04-18 23:41:23 +00:00
|
|
|
|
|
|
|
|
|
# compile a simple module using the JS backend
|
|
|
|
|
system bin/"agda", "--js", simpletest
|
|
|
|
|
|
|
|
|
|
# test the GHC backend
|
|
|
|
|
if build.with? "ghc"
|
|
|
|
|
cabal_sandbox do
|
|
|
|
|
cabal_install "text"
|
|
|
|
|
dbpath = Dir["#{testpath}/.cabal-sandbox/*-packages.conf.d"].first
|
|
|
|
|
dbopt = "--ghc-flag=-package-db=#{dbpath}"
|
|
|
|
|
|
|
|
|
|
# compile and run a simple program
|
|
|
|
|
system bin/"agda", "-c", dbopt, iotest
|
|
|
|
|
assert_equal "", shell_output(testpath/"IOTest")
|
|
|
|
|
|
|
|
|
|
# compile and run a program that uses the standard library
|
|
|
|
|
if build.with? "stdlib"
|
|
|
|
|
system bin/"agda", "-c", "-i", lib/"agda"/"src", dbopt, stdlibiotest
|
|
|
|
|
assert_equal "Hello, world!", shell_output(testpath/"StdlibIOTest")
|
|
|
|
|
end
|
|
|
|
|
end
|
2015-02-09 20:46:31 +00:00
|
|
|
|
end
|
2015-01-21 05:10:45 +00:00
|
|
|
|
end
|
|
|
|
|
end
|