From 25f47799b00a754ccd02d4f3c34441a14c90067a Mon Sep 17 00:00:00 2001 From: Julien Moutinho <julm+symantic-parser@sourcephile.fr> Date: Sun, 4 Jul 2021 04:59:59 +0200 Subject: [PATCH] cabal: clean up --- Makefile | 37 ++++++------------- benchmarks/Brainfuck.hs | 3 -- default.nix | 12 +++--- .../Brainfuck/SymanticParser/Grammar.hs | 7 ---- src/Symantic/Typed/View.hs | 1 + symantic-parser.cabal | 25 +++++++------ 6 files changed, 32 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index c04066e..d1c9dc6 100644 --- a/Makefile +++ b/Makefile @@ -11,23 +11,23 @@ project := $(patsubst %.cabal,%,$(cabal)) all: build build: - cabal build + cabal build $(CABAL_BUILD_FLAGS) clean c: cabal clean repl: - cabal repl $(project) + cabal repl $(CABAL_REPL_FLAGS) $(project) ghcid: - ghcid -c 'cabal repl $(project) --repl-options "$(REPL_OPTIONS)"' --reverse-errors + ghcid -c 'cabal repl $(CABAL_REPL_FLAGS) $(project) --repl-options "$(REPL_OPTIONS)"' --reverse-errors .PHONY: parsers parsers: - cabal build $(project):parsers + cabal build $(CABAL_BUILD_FLAGS) $(project):parsers parsers/repl: - cabal repl $(project):parsers + cabal repl $(CABAL_REPL_FLAGS) $(project):parsers parsers/ghcid: - ghcid -c 'cabal repl $(project):parsers --repl-options "$(REPL_OPTIONS)"' --reverse-errors + ghcid -c 'cabal repl $(CABAL_REPL_FLAGS) $(project):parsers --repl-options "$(REPL_OPTIONS)"' --reverse-errors parsers/prof-th: cabal v2-build lib:$(project) --enable-profiling $(GHC_PROF_OPTIONS) --write-ghc-environment-files=always - cabal build $(project):parsers $(CABAL_BUILD_FLAGS) \ + cabal build $(CABAL_BUILD_FLAGS) $(project):parsers \ --enable-profiling $(GHC_PROF_OPTIONS) \ --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))" @@ -49,9 +49,9 @@ tests/prof-th: --enable-profiling $(GHC_PROF_OPTIONS) \ --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))" tests/repl: - cabal repl --enable-tests $(project)-test + cabal repl $(CABAL_REPL_FLAGS) --enable-tests $(project)-test tests/ghcid: - ghcid -c 'cabal repl $(project):tests --test-options "$(TEST_OPTIONS)"' --reverse-errors + ghcid -c 'cabal repl $(CABAL_REPL_FLAGS) $(project):tests --test-options "$(TEST_OPTIONS)"' --reverse-errors %/accept: TEST_OPTIONS += --accept %/accept: % @@ -72,7 +72,7 @@ benchmarks/html/$(version).html: mkdir -p benchmarks/html cabal bench $(CABAL_BENCH_FLAGS) --benchmark-options "$(BENCHMARK_OPTIONS)" benchmarks/repl: - cabal repl --enable-benchmarks $(project)-benchmark + cabal repl $(CABAL_REPL_FLAGS) --enable-benchmarks $(project)-benchmark benchmarks/prof-time: $(project)-benchmark.eventlog.json benchmarks/prof-heap: $(project)-benchmark.eventlog.html .PHONY: $(project)-benchmark.eventlog @@ -112,21 +112,6 @@ nix-build: nix-relock: nix flake update --recreate-lock-file nix-repl: - nix -L develop --command cabal repl + nix -L develop --command cabal repl $(CABAL_REPL_FLAGS) nix-shell: nix -L develop - -.PHONY: debug-ppr -debug-ppr: debug-ppr/PprSplice.hs debug-ppr/AutoSplice.hs -debug-ppr/PprSplice.hs.ppr: parsers/Parsers/Brainfuck/SymanticParser/PprSplice.hs.ppr Makefile - mkdir -p $(@D) - sed $< >$@ -e '1s/^/parser = /' -e 's/\x00//g' -debug-ppr/AutoSplice.dump-splices: dist-newstyle/build/x86_64-linux/ghc-9.0.1/symantic-parser-$(version)/l/parsers/build/parsers/parsers/Parsers/Brainfuck/SymanticParser/AutoSplice.dump-splices Makefile - mkdir -p $(@D) - sed $< >$@ -e '1,/^ ======>/d;' -e '4s/^/parser = /' -e 's/\x00//g' -%.hs: %.hs.ppr - ormolu -m stdout >$@ -o -XBangPatterns -o -XUnboxedTuples -o -XMagicHash -o -XTypeApplications -o -XUnboxedTuples <$< - #sed -i $@ -e 'N;s/\n\s*#)/ #)/;P;D' -%.hs: %.dump-splices - ormolu -m stdout >$@ -o -XBangPatterns -o -XUnboxedTuples -o -XMagicHash -o -XTypeApplications -o -XUnboxedTuples <$< - #sed -i $@ -e 'N;s/\n\s*#)/ #)/;P;D' diff --git a/benchmarks/Brainfuck.hs b/benchmarks/Brainfuck.hs index 0c25946..49c5263 100644 --- a/benchmarks/Brainfuck.hs +++ b/benchmarks/Brainfuck.hs @@ -9,8 +9,6 @@ import Control.Monad ((=<<)) import Criterion.Main (Benchmark, bench, bgroup, env, nf) import Data.Function (($)) import Data.Semigroup (Semigroup(..)) -import Data.String (String) -import Data.Text (Text) import qualified Data.Attoparsec.ByteString as AP.ByteString import qualified Data.Attoparsec.Text as AP.Text import qualified Data.ByteString as BS @@ -19,7 +17,6 @@ import qualified Data.List as List import qualified Data.Text.IO as Text import qualified System.IO as IO -import qualified Symantic.Parser as SP import qualified Parsers.Brainfuck.Attoparsec as AP.Brainfuck import qualified Parsers.Brainfuck.Handrolled as HR.Brainfuck import qualified Parsers.Brainfuck.SymanticParser as SP.Brainfuck diff --git a/default.nix b/default.nix index 22a7dfe..f599f8a 100644 --- a/default.nix +++ b/default.nix @@ -16,7 +16,7 @@ let hs-speedscope = doJailbreak (unmarkBroken hsuper.hs-speedscope); eventlog2html = doJailbreak (unmarkBroken hsuper.eventlog2html); trie-simple = doJailbreak (unmarkBroken hsuper.trie-simple); - symantic-parser = doBenchmark (buildFromSdist (hself.callCabal2nix "symantic-parser" ./. {})); + symantic-parser = buildFromSdist (hself.callCabal2nix "symantic-parser" ./. {}); hlint = hsuper.hlint_3_3_1.overrideScope (self: super: { ghc-lib-parser = overrideCabal self.ghc-lib-parser_9_0_1_20210324 { doHaddock = false; @@ -29,22 +29,24 @@ in hs.symantic-parser // { shell = hs.shellFor { doBenchmark = true; packages = p: [ p.symantic-parser ]; + # FIXME: remove when Nixpkgs' haskellPackages.ormolu is no longer broken + CABAL_TEST_FLAGS = "-fdisable-ormolu-check"; nativeBuildInputs = [ hs.cabal-install + hs.eventlog2html hs.ghc-events + hs.ghcid + hs.hlint hs.hs-speedscope + hs.ormolu hs.profiteur - hs.eventlog2html - hs.ghcid #hs.threadscope #hs.ghc-events-analyze - hs.hlint #hs.haskell-language-server #hs.hpc ]; buildInputs = [ #hs.ghcid - pkgs.ormolu pkgs.cabal2nix #hs.hlint #pkgs.nixpkgs-fmt diff --git a/parsers/Parsers/Brainfuck/SymanticParser/Grammar.hs b/parsers/Parsers/Brainfuck/SymanticParser/Grammar.hs index 0ca453e..9f89675 100644 --- a/parsers/Parsers/Brainfuck/SymanticParser/Grammar.hs +++ b/parsers/Parsers/Brainfuck/SymanticParser/Grammar.hs @@ -43,10 +43,3 @@ grammar = whitespace SP.*> bf (SP.token (coerceEnum @_ @tok ']')) ($(SP.prodCon 'Loop) SP.<$> bf) _ -> Prelude.undefined - -reproGrammar :: forall tok repr. - CoerceEnum Char tok => - CoerceEnum tok Char => - SP.Grammarable tok repr => - repr [tok] -reproGrammar = SP.many (SP.item @tok) diff --git a/src/Symantic/Typed/View.hs b/src/Symantic/Typed/View.hs index ba1aa89..0a90d0e 100644 --- a/src/Symantic/Typed/View.hs +++ b/src/Symantic/Typed/View.hs @@ -40,6 +40,7 @@ runView (ViewApp f x) env = runView x env{viewEnv_op = (op, SideR) } where op = infixN 10 +-- | Unusual, but enables to leverage default definition of methods. type instance Output View = View instance Trans View View where trans = Fun.id diff --git a/symantic-parser.cabal b/symantic-parser.cabal index a89c49e..53dda53 100644 --- a/symantic-parser.cabal +++ b/symantic-parser.cabal @@ -8,10 +8,8 @@ description: . This is an alternative but less powerful/reviewed implementation of [ParsleyHaskell](https://github.com/J-mie6/ParsleyHaskell). - See the paper by Jamie Willis, Nicolas Wu, and Matthew - Pickering, admirably well presented at ICFP-2020: [Staged - Selective Parser - Combinators](https://icfp20.sigplan.org/details/icfp-2020-papers/20/Staged-Selective-Parser-Combinators). + See the paper by Jamie Willis, Nicolas Wu, and Matthew Pickering, + admirably well presented at ICFP-2020: [Staged Selective Parser Combinators](https://icfp20.sigplan.org/details/icfp-2020-papers/20/Staged-Selective-Parser-Combinators). license: AGPL-3.0-or-later author: Julien Moutinho <julm+symantic-parser@sourcephile.fr> maintainer: Julien Moutinho <julm+symantic-parser@sourcephile.fr> @@ -31,7 +29,7 @@ extra-source-files: flake.lock flake.nix Makefile - parsers/Parsers/*/inputs/* + parsers/Parsers/Brainfuck/inputs/*.bf shell.nix test/Golden/**/*.txt extra-tmp-files: @@ -47,6 +45,12 @@ flag dump-core manual: True default: False +flag disable-ormolu-check + description: Remove ormolu from build-tool-depends. + Temporary hack while Nixpkgs' haskellPackages.ormolu remains broken. + manual: True + default: False + common boilerplate default-language: Haskell2010 default-extensions: @@ -149,8 +153,6 @@ library parsers TypeApplications, TypeFamilies, TypeOperators - ghc-options: -O2 - -- -ddump-to-file -ddump-simpl-stats -ddump-splices build-depends: symantic-parser, attoparsec >= 0.13, @@ -191,7 +193,6 @@ test-suite symantic-parser-test Paths_symantic_parser autogen-modules: Paths_symantic_parser - ghc-options: -O2 ghc-prof-options: -fexternal-interpreter build-depends: symantic-parser, @@ -219,9 +220,9 @@ test-suite symantic-parser-test -- tasty-quickcheck, unix >= 2.7, unordered-containers - -- FIXME: add when haskellPackages.ormolu has been unbroken - -- build-tool-depends: - -- ormolu:ormolu >= 1.5 + if !flag(disable-ormolu-check) + build-tool-depends: + ormolu:ormolu >= 1.5 if flag(dump-core) build-depends: dump-core ghc-options: -fplugin=DumpCore @@ -238,7 +239,7 @@ benchmark symantic-parser-benchmark autogen-modules: Paths_symantic_parser default-extensions: - ghc-options: -O2 -fno-enable-th-splice-warnings + ghc-options: -fno-enable-th-splice-warnings ghc-prof-options: -fexternal-interpreter build-depends: base >= 4.6 && < 5, -- 2.47.0