-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makefile: also generate HTML + Haskell code
- More modular haskell project structure: + A single `Lib.hs` file now re-exports all (exposed) modules. + A single `Main.hs` acts as the entry-point for running the project. - the Makefile is still not entirely polished and will be improved later + e.g. too much duplication of similar commands
- Loading branch information
1 parent
d626ddd
commit bcde52c
Showing
13 changed files
with
154 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ result* | |
src/latex/Ledger/* | ||
src/latex/MidnightExample/* | ||
src/latex/bclogo.sty | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.PHONY: all docs html codeGen hsBuild | ||
|
||
all: | ||
$(MAKE) -C src/ | ||
docs: | ||
$(MAKE) -C src/ docs | ||
html: | ||
$(MAKE) -C src/ html | ||
codeGen: | ||
$(MAKE) -C src/ codeGen | ||
hsBuild: | ||
$(MAKE) -C src/ hsBuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ TxId = ℕ | |
Ix = ℕ | ||
Epoch = ℕ | ||
AuxiliaryData = ⊤ | ||
Network = ⊤ | ||
|
||
TxIn = Pair TxId Ix | ||
TxOut = Pair Addr Coin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Lib | ||
( module MAlonzo.Code.Ledger.Foreign.LedgerTypes | ||
, module MAlonzo.Code.Ledger.Foreign.HSLedger | ||
) where | ||
|
||
import MAlonzo.Code.Ledger.Foreign.LedgerTypes | ||
import MAlonzo.Code.Ledger.Foreign.HSLedger | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
cabal-version: 2.4 | ||
name: agda-ledger-executable-spec | ||
name: cardano-ledger | ||
version: 0.1.0.0 | ||
synopsis: | ||
|
||
|
@@ -18,23 +18,31 @@ maintainer: [email protected] | |
-- category: | ||
extra-source-files: CHANGELOG.md | ||
|
||
executable main | ||
main-is: Main.hs | ||
ghc-options: -Wno-missing-home-modules | ||
build-depends: | ||
base, | ||
text, | ||
ieee, | ||
tree-diff, | ||
cardano-ledger | ||
|
||
library | ||
exposed-modules: | ||
HSLedgerTest | ||
|
||
other-extensions: | ||
CPP PolyKinds EmptyDataDecls EmptyCase ExistentialQuantification | ||
ScopedTypeVariables NoMonomorphismRestriction RankNTypes | ||
PatternSynonyms DeriveGeneric | ||
|
||
Lib | ||
build-depends: | ||
base, | ||
text, | ||
ieee, | ||
tree-diff | ||
|
||
ghc-options: -Wno-overlapping-patterns | ||
hs-source-dirs: . | ||
hs-source-dirs: . | ||
default-language: Haskell2010 | ||
ghc-options: | ||
-Wno-overlapping-patterns | ||
other-extensions: | ||
CPP PolyKinds EmptyDataDecls EmptyCase ExistentialQuantification | ||
ScopedTypeVariables NoMonomorphismRestriction RankNTypes | ||
PatternSynonyms DeriveGeneric | ||
-- This will be generated automatically when building with nix | ||
other-modules: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,83 @@ | ||
LATEX=latexmk -xelatex -shell-escape -halt-on-error | ||
# Constants | ||
AGDA?=agda | ||
OUT_DIR?=../dist | ||
LATEX?=latexmk -xelatex -shell-escape -halt-on-error | ||
LATEX_DIR=latex | ||
PRE=$(addprefix $(LATEX_DIR)/, \ | ||
agda.sty agda-latex-macros.sty iohk.sty fonts/* preamble.tex) | ||
AGDA=/home/omelkonian/IOHK/agdaWithStdLibMeta/bin/agda \ | ||
--latex --latex-dir=$(LATEX_DIR) # --only-scope-checking | ||
HTML_DIR=$(OUT_DIR)/html | ||
HS_DIR=$(OUT_DIR)/MAlonzo | ||
HS_DIR_LEDGER=$(HS_DIR)/Ledger | ||
HS_DIR_MIDNIGHT=$(HS_DIR)/MidnightExample | ||
|
||
.PHONY: default clean all | ||
.PHONY: default clean all docs html codeGen hsBuild | ||
default: all | ||
|
||
all: $(latexFiles) | ||
|
||
# Compile a literate Agda file to LaTeX. | ||
# Agda -> LaTeX -> PDF | ||
latexFiles=$(patsubst %.lagda, $(LATEX_DIR)/%.tex, \ | ||
$(shell find . -name '*.lagda' | sed 's|\.\/||g')) | ||
$(latexFiles): $(LATEX_DIR)/%.tex: %.lagda | ||
@echo "Compiling $<" | ||
$(AGDA) $< | ||
$(AGDA) --latex --latex-dir=$(LATEX_DIR) $< # --only-scope-checking | ||
|
||
../cardano-ledger.pdf: $(LATEX_DIR)/Ledger/PDF.tex $(latexFiles) $(PRE) | ||
$(OUT_DIR)/cardano-ledger.pdf: $(LATEX_DIR)/Ledger/PDF.tex $(latexFiles) $(PRE) | ||
@echo "Generating $@" | ||
cd $(LATEX_DIR) && $(LATEX) $(subst $(LATEX_DIR)/,, $<) | ||
mv $(LATEX_DIR)/PDF.pdf $@ | ||
|
||
../midnight-example.pdf: $(LATEX_DIR)/MidnightExample/PDF.tex $(latexFiles) $(PRE) | ||
$(OUT_DIR)/midnight-example.pdf: $(LATEX_DIR)/MidnightExample/PDF.tex $(latexFiles) $(PRE) | ||
@echo "Generating $@" | ||
cd $(LATEX_DIR) && $(LATEX) $(subst $(LATEX_DIR)/,, $<) | ||
mv $(LATEX_DIR)/PDF.pdf $@ | ||
|
||
all: | ||
$(MAKE) ../cardano-ledger.pdf | ||
$(MAKE) ../midnight-example.pdf | ||
# Agda -> HTML | ||
$(HTML_DIR)/Ledger.PDF.html : Ledger/PDF.lagda | ||
@echo "Generating $@" | ||
$(AGDA) --html --html-dir $(HTML_DIR) $< | ||
$(HTML_DIR)/MidnightExample.PDF.html : MidnightExample/PDF.lagda | ||
@echo "Generating $@" | ||
$(AGDA) --html --html-dir $(HTML_DIR) $< | ||
|
||
# Agda -> Haskell | ||
LEDGER_CABAL=cardano-ledger.cabal | ||
$(HS_DIR_LEDGER)/Foreign/HSLedger.hs: Ledger/Foreign/HSLedger.agda | ||
@echo "Generating $@" | ||
mkdir -p $(HS_DIR_LEDGER) | ||
cp Ledger/*.hs $(HS_DIR_LEDGER)/ | ||
cp Ledger/$(LEDGER_CABAL) $(HS_DIR_LEDGER)/ | ||
$(AGDA) -c --ghc-dont-call-ghc --compile-dir $(HS_DIR_LEDGER) $< | ||
find $(HS_DIR_LEDGER)/MAlonzo -name "*.hs" -print \ | ||
| sed "s#^$(HS_DIR_LEDGER)/# #;s#\.hs##;s#/#.#g" \ | ||
>> $(HS_DIR_LEDGER)/$(LEDGER_CABAL) | ||
|
||
MIDNIGHT_CABAL=midnight-example.cabal | ||
$(HS_DIR_MIDNIGHT)/HSLedger.hs: MidnightExample/HSLedger.agda | ||
mkdir -p $(HS_DIR_MIDNIGHT) | ||
@echo "Generating $@" | ||
cp MidnightExample/*.hs $(HS_DIR_MIDNIGHT)/ | ||
cp MidnightExample/$(MIDNIGHT_CABAL) $(HS_DIR_MIDNIGHT)/ | ||
$(AGDA) -c --ghc-dont-call-ghc --compile-dir $(HS_DIR_MIDNIGHT) $< | ||
find $(HS_DIR_MIDNIGHT)/MAlonzo -name "*.hs" -print \ | ||
| sed "s#^$(HS_DIR_MIDNIGHT)/# #;s#\.hs##;s#/#.#g" \ | ||
>> $(HS_DIR_MIDNIGHT)/$(MIDNIGHT_CABAL) | ||
|
||
# User commands | ||
docs: | ||
$(MAKE) $(OUT_DIR)/cardano-ledger.pdf | ||
$(MAKE) $(OUT_DIR)/midnight-example.pdf | ||
html: | ||
$(MAKE) $(HTML_DIR)/Ledger.PDF.html | ||
$(MAKE) $(HTML_DIR)/MidnightExample.PDF.html | ||
codeGen: | ||
$(MAKE) $(HS_DIR_LEDGER)/Foreign/HSLedger.hs | ||
$(MAKE) $(HS_DIR_MIDNIGHT)/HSLedger.hs | ||
hsBuild: $(HS_DIR_LEDGER)/Main.hs $(HS_DIR_MIDNIGHT)/Main.hs | ||
cd $(HS_DIR_LEDGER) && cabal run -- main | ||
cd $(HS_DIR_MIDNIGHT) && cabal run -- main | ||
all: docs html codeGen hsBuild | ||
|
||
clean: | ||
rm -rf $(LATEX_DIR)/Ledger/ $(LATEX_DIR)/MidnightExample \ | ||
../cardano-ledger.pdf ../midnight-example.pdf | ||
rm -rf $(LATEX_DIR)/Ledger/ $(LATEX_DIR)/MidnightExample $(LATEX_DIR)/PDF.* \ | ||
$(OUT_DIR)/ | ||
|
||
# TODO: Agda HTML generation | ||
# TODO: Haskell code generation | ||
# TODO: use this into `default.nix` instead of repeating the same kind of commands | ||
# TODO: integrate into `default.nix` to remove duplication |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Lib | ||
( module MAlonzo.Code.MidnightExample.HSLedger | ||
, module MAlonzo.Code.MidnightExample.Types | ||
) where | ||
|
||
import MAlonzo.Code.MidnightExample.HSLedger | ||
import MAlonzo.Code.MidnightExample.Types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
cabal-version: 2.4 | ||
name: agda-ledger-executable-spec-midnight | ||
name: midnight-example | ||
version: 0.1.0.0 | ||
synopsis: | ||
|
||
|
@@ -18,22 +18,30 @@ maintainer: [email protected] | |
-- category: | ||
extra-source-files: CHANGELOG.md | ||
|
||
executable main | ||
main-is: Main.hs | ||
ghc-options: -Wno-missing-home-modules | ||
build-depends: | ||
base, | ||
text, | ||
ieee, | ||
midnight-example | ||
|
||
library | ||
exposed-modules: | ||
Main | ||
|
||
other-extensions: | ||
CPP PolyKinds EmptyDataDecls EmptyCase ExistentialQuantification | ||
ScopedTypeVariables NoMonomorphismRestriction RankNTypes | ||
PatternSynonyms | ||
|
||
Lib | ||
build-depends: | ||
base, | ||
text, | ||
ieee | ||
|
||
ghc-options: -Wno-overlapping-patterns | ||
hs-source-dirs: . | ||
hs-source-dirs: . | ||
default-language: Haskell2010 | ||
ghc-options: | ||
-Wno-overlapping-patterns | ||
other-extensions: | ||
CPP PolyKinds EmptyDataDecls EmptyCase ExistentialQuantification | ||
ScopedTypeVariables NoMonomorphismRestriction RankNTypes | ||
PatternSynonyms | ||
|
||
-- This will be generated automatically when building with nix | ||
other-modules: |