Skip to content

Commit 6539b48

Browse files
committed
Migrate from String to Text + add NoImplicitPrelude compatibility
User-facing code (e.g. `Axel.Parse.AST.Expression`, `Axel.Parse.AST.toAxel`, `SourcePosition`) still uses `String`, so that Axel projects don't need direct dependencies on `text`. Other changes: - `FilePath` is now a newtype - A project-specific Prelude is now in use (`Axel.Prelude`) - Regexes were replaced with (Megaparsec) parsers. - Probably other small stuff. Fixes axellang#38.
1 parent b0cd9d6 commit 6539b48

File tree

99 files changed

+1126
-891
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1126
-891
lines changed

Diff for: .ghci

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
:set -XFlexibleContexts
21
:set -XPartialTypeSignatures

Diff for: .hindent.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -1 +1,26 @@
11
force-trailing-newline: true
2+
# NOTE Keep in sync with `package.yaml#default-extensions` and `.hlint.yaml#arguments`.
3+
extensions:
4+
- BangPatterns
5+
- ConstraintKinds
6+
- DataKinds
7+
- DeriveDataTypeable
8+
- DeriveFoldable
9+
- DeriveFunctor
10+
- DeriveGeneric
11+
- DeriveTraversable
12+
- FlexibleContexts
13+
- FlexibleInstances
14+
- FunctionalDependencies
15+
- GeneralizedNewtypeDeriving
16+
- InstanceSigs
17+
- KindSignatures
18+
- LambdaCase
19+
- MultiParamTypeClasses
20+
- OverloadedStrings
21+
- PolyKinds
22+
- RankNTypes
23+
- StandaloneDeriving
24+
- TupleSections
25+
- TypeApplications
26+
- TypeOperators

Diff for: .hlint.yaml

+33-1
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,46 @@
1010
# Generalise map to fmap, ++ to <>
1111
# - group: {name: generalise, enabled: true}
1212

13+
# NOTE Keep in sync with `package.yaml#default-extensions` and `.hindent.yaml#extensions`.
14+
- arguments:
15+
- -XBangPatterns
16+
- -XConstraintKinds
17+
- -XDataKinds
18+
- -XDeriveDataTypeable
19+
- -XDeriveFoldable
20+
- -XDeriveFunctor
21+
- -XDeriveGeneric
22+
- -XDeriveTraversable
23+
- -XFlexibleContexts
24+
- -XFlexibleInstances
25+
- -XFunctionalDependencies
26+
- -XGeneralizedNewtypeDeriving
27+
- -XInstanceSigs
28+
- -XKindSignatures
29+
- -XLambdaCase
30+
- -XMultiParamTypeClasses
31+
- -XNoImplicitPrelude
32+
- -XOverloadedStrings
33+
- -XPolyKinds
34+
- -XRankNTypes
35+
- -XStandaloneDeriving
36+
- -XTupleSections
37+
- -XTypeApplications
38+
- -XTypeOperators
39+
1340
- modules:
1441
- {name: Axel.Utils.Debug, within: []}
1542
- {name: Debug.Trace, within: []}
43+
- {name: [Prelude], as: Prelude}
1644
- {name: Text.Megaparsec.Debug, within: []}
1745

1846
- functions:
19-
- {name: unsafePerformIO, within: [Axel.Parse.AST]}
47+
- {name: unsafeEmbedIO, within: []}
48+
- {name: unsafePerformIO, within: []}
2049
- {name: undefined, within: []}
2150

2251
- warn: {lhs: "head x", rhs: "Axel.Utils.List.unsafeHead x"}
52+
2353
- warn: {lhs: "fromJust (head' x)", rhs: "Axel.Utils.List.unsafeHead x"}
2454

2555
- warn: {lhs: "fromJust (down x)", rhs: "Axel.Utils.Zipper.unsafeDown x"}
@@ -33,3 +63,5 @@
3363
- warn: {lhs: "unsafeTeeS x", rhs: "x"}
3464
- warn: {lhs: "unsafeTee' f x", rhs: "x"}
3565
- warn: {lhs: "unsafeTeeS' f x", rhs: "x"}
66+
67+
- warn: {lhs: "unsafeReportTime message x", rhs: "x"}

Diff for: app/Main.axel

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
(pragma "LANGUAGE DataKinds")
2-
(pragma "LANGUAGE TypeApplications")
31
(module Main)
4-
(raw "import Prelude hiding (putStrLn)")
52
(import Axel.Eff.App (AppEffs runApp))
63
(import Axel.Eff.Console (putStrLn))
74
(import Axel.Eff.Ghci (withGhci))
85
(import Axel.Haskell.File (convertFileInPlace transpileFileInPlace))
96
(import Axel.Haskell.Project (buildProject runProject))
107
(import Axel.Haskell.Stack (axelStackageVersion))
8+
(importq Axel.Parse.AST AST all)
119
(import Axel.Parse.Args ((Command Convert File Project Version) commandParser))
1210
(import Control.Monad (void))
1311
(importq Data.Map Map (empty))
1412
(import Options.Applicative (<**> execParser helper info progDesc))
1513
(importq Polysemy Sem all)
1614
(importq Polysemy.State Sem all)
17-
(def app ((-> Command) (Sem.Sem AppEffs Unit)) (((Convert filePath)) (void (convertFileInPlace filePath))) (((File filePath)) (void ((Sem.evalState Map.empty) (withGhci (transpileFileInPlace filePath))))) (((Project)) (>> buildProject runProject)) (((Version)) (putStrLn (<> "Axel version " axelStackageVersion))))
18-
(def main (IO Unit)
19-
(()
20-
(do'
21-
(<- modeCommand (execParser (info {commandParser <**> helper} (progDesc "The command to run."))))
22-
(runApp (app modeCommand)))))
15+
(raw "import Prelude hiding (putStrLn)")
16+
(def app ((-> Command) (Sem.Sem AppEffs Unit)) (((Convert filePath)) (void (convertFileInPlace filePath))) (((File filePath)) (void (Sem.evalState Map.empty (withGhci (transpileFileInPlace filePath))))) (((Project)) (>> buildProject runProject)) (((Version)) (putStrLn (<> "Axel version " axelStackageVersion))))
17+
(def main (IO Unit) (() (do' (<- modeCommand (execParser (info (<**> commandParser helper) (progDesc "The command to run.")))) (runApp (app modeCommand)))))

Diff for: app/Main.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
{-# LANGUAGE DataKinds #-}
2-
{-# LANGUAGE TypeApplications #-}
31
module Main where
2+
import qualified Prelude as GHCPrelude
43
import qualified Axel.Parse.AST as AST
5-
import Prelude hiding (putStrLn)
64
import Axel.Eff.App(AppEffs,runApp)
75
import Axel.Eff.Console(putStrLn)
86
import Axel.Eff.Ghci(withGhci)
97
import Axel.Haskell.File(convertFileInPlace,transpileFileInPlace)
108
import Axel.Haskell.Project(buildProject,runProject)
119
import Axel.Haskell.Stack(axelStackageVersion)
10+
import qualified Axel.Parse.AST as AST
1211
import Axel.Parse.Args(Command(Convert,File,Project,Version),commandParser)
1312
import Control.Monad(void)
1413
import qualified Data.Map as Map(empty)
1514
import Options.Applicative((<**>),execParser,helper,info,progDesc)
1615
import qualified Polysemy as Sem
1716
import qualified Polysemy.State as Sem
17+
import Prelude hiding (putStrLn)
1818
app (Convert filePath) = (void (convertFileInPlace filePath))
19-
app (File filePath) = (void ((Sem.evalState Map.empty) (withGhci (transpileFileInPlace filePath))))
19+
app (File filePath) = (void (Sem.evalState Map.empty (withGhci (transpileFileInPlace filePath))))
2020
app (Project ) = ((>>) buildProject runProject)
2121
app (Version ) = (putStrLn ((<>) "Axel version " axelStackageVersion))
2222
app :: (((->) Command) (Sem.Sem AppEffs ()))

Diff for: axel.cabal

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cabal-version: 1.12
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: 0f084304e59fc78404d9f395d857b72c4f50a026df11d5a2c5cefd0e2f5502f3
7+
-- hash: b03a46ed7e2a855ffd81c35144f96d3327c2817b9d9e4c814fc3798bc2fcbd52
88

99
name: axel
1010
version: 0.0.11
@@ -68,7 +68,6 @@ library
6868
Axel.Haskell.Convert
6969
Axel.Haskell.Error
7070
Axel.Haskell.File
71-
Axel.Haskell.FilePath
7271
Axel.Haskell.Language
7372
Axel.Haskell.Macros
7473
Axel.Haskell.Project
@@ -78,23 +77,26 @@ library
7877
Axel.Parse
7978
Axel.Parse.Args
8079
Axel.Parse.AST
80+
Axel.Prelude
8181
Axel.Sourcemap
8282
Axel.Utils.Debug
8383
Axel.Utils.Display
84+
Axel.Utils.FilePath
8485
Axel.Utils.Foldable
8586
Axel.Utils.Function
8687
Axel.Utils.Json
8788
Axel.Utils.List
8889
Axel.Utils.Maybe
8990
Axel.Utils.Monad
9091
Axel.Utils.Recursion
91-
Axel.Utils.String
92+
Axel.Utils.Text
9293
Axel.Utils.Tuple
9394
Axel.Utils.Zipper
9495
other-modules:
9596
Paths_axel
9697
hs-source-dirs:
9798
src
99+
default-extensions: BangPatterns ConstraintKinds DataKinds DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses NoImplicitPrelude OverloadedStrings PolyKinds RankNTypes StandaloneDeriving TupleSections TypeApplications TypeOperators
98100
ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-implicit-prelude -Wno-missed-specialisations -Wno-missing-import-lists -Wno-missing-export-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe -optP-Wno-nonportable-include-path -fplugin=Polysemy.Plugin -O2 -flate-specialise -fspecialise-aggressively
99101
build-tool-depends:
100102
hpack:hpack
@@ -116,16 +118,15 @@ library
116118
, lens
117119
, lens-aeson
118120
, megaparsec
121+
, mono-traversable
119122
, optparse-applicative
120123
, polysemy
121124
, polysemy-plugin
122125
, process
123126
, profunctors
124127
, random
125-
, regex-pcre
126128
, singletons
127129
, split
128-
, strict
129130
, tasty
130131
, tasty-discover
131132
, tasty-golden
@@ -148,6 +149,7 @@ executable axel
148149
Paths_axel
149150
hs-source-dirs:
150151
app
152+
default-extensions: BangPatterns ConstraintKinds DataKinds DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses NoImplicitPrelude OverloadedStrings PolyKinds RankNTypes StandaloneDeriving TupleSections TypeApplications TypeOperators
151153
ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-implicit-prelude -Wno-missed-specialisations -Wno-missing-import-lists -Wno-missing-export-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe -optP-Wno-nonportable-include-path -fplugin=Polysemy.Plugin -O2 -flate-specialise -fspecialise-aggressively -threaded -rtsopts -with-rtsopts=-N
152154
build-tool-depends:
153155
hpack:hpack
@@ -170,16 +172,15 @@ executable axel
170172
, lens
171173
, lens-aeson
172174
, megaparsec
175+
, mono-traversable
173176
, optparse-applicative
174177
, polysemy
175178
, polysemy-plugin
176179
, process
177180
, profunctors
178181
, random
179-
, regex-pcre
180182
, singletons
181183
, split
182-
, strict
183184
, tasty
184185
, tasty-discover
185186
, tasty-golden
@@ -225,6 +226,7 @@ test-suite axel-test
225226
Paths_axel
226227
hs-source-dirs:
227228
test
229+
default-extensions: BangPatterns ConstraintKinds DataKinds DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses NoImplicitPrelude OverloadedStrings PolyKinds RankNTypes StandaloneDeriving TupleSections TypeApplications TypeOperators
228230
ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-implicit-prelude -Wno-missed-specialisations -Wno-missing-import-lists -Wno-missing-export-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe -optP-Wno-nonportable-include-path -fplugin=Polysemy.Plugin -O2 -flate-specialise -fspecialise-aggressively -threaded -rtsopts -with-rtsopts=-N
229231
build-tool-depends:
230232
hpack:hpack
@@ -247,16 +249,15 @@ test-suite axel-test
247249
, lens
248250
, lens-aeson
249251
, megaparsec
252+
, mono-traversable
250253
, optparse-applicative
251254
, polysemy
252255
, polysemy-plugin
253256
, process
254257
, profunctors
255258
, random
256-
, regex-pcre
257259
, singletons
258260
, split
259-
, strict
260261
, tasty
261262
, tasty-discover
262263
, tasty-golden

0 commit comments

Comments
 (0)