Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agda Setup #2

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ packages:
laborations/lab2/haskell
laborations/lab3/haskell
laborations/lab4/haskell

laborations/lab2/agda
3 changes: 3 additions & 0 deletions laborations/lab2/agda/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Main (module X) where

import MAlonzo.Code.Qlab2 as X (main)
36 changes: 36 additions & 0 deletions laborations/lab2/agda/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- Programming Language Technology (Chalmers DAT151 / GU DIT231).
-- (C) Andreas Abel 2023
-- All rights reserved.

-- | Hook BNFC into the cabal build process to generate AST, lexer, parser, and printer definitions.

import Distribution.Simple (defaultMainWithHooks, simpleUserHooks, buildHook)
import Distribution.Simple.BuildPaths (autogenPackageModulesDir)
import System.Process (callProcess)

main :: IO ()
main = defaultMainWithHooks simpleUserHooks
{ buildHook = \ packageDescription localBuildInfo userHooks buildFlags -> do
-- For simplicity, generate files in build/global-autogen;
-- there they are available to all components of the package.
let dir = autogenPackageModulesDir localBuildInfo
callProcess "bnfc"
[ "-o", dir
, "-d"
, "CMM.cf"
]
callProcess "agda"
[ "--ghc", "--ghc-dont-call-ghc"
, "src/lab2.agda"
]
callProcess "rm"
[ "-rf"
, dir ++ "/MAlonzo"
]
callProcess "mv"
[ "src/MAlonzo"
, dir ++ "/"
]
-- Run the build process.
buildHook simpleUserHooks packageDescription localBuildInfo userHooks buildFlags
}
16 changes: 11 additions & 5 deletions laborations/lab2/agda/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,28 @@ tested-with:
- GHC == 8.6.5
- GHC == 8.4.4

dependencies:
- base >= 4.9 && < 5
custom-setup:
dependencies:
- Cabal >= 2.0 && < 4
- base >= 4.11 && < 5
- process

executables:
lab2:
# files in MAlonzo/Code are qualified modules
# files in CMM are qualified modules
source-dirs:
- .
- src
main: MAlonzo.Code.Qlab2
# - src
main: Main
generated-other-modules:
- MAlonzo.Code.Qlab2
dependencies:
- base >= 4.11 && < 5
- array
- text
- filepath
- process
- text

# exclude some modules
when:
Expand Down