1
1
mirror of https://github.com/anoma/juvix.git synced 2024-08-17 12:10:21 +03:00

Update stackage resolver to LTS 21.6 (#2275)

Stack LTS 21.6 uses GHC 9.4.5, binaries for HLS are available via ghcup.

Changes required:

1. Fix warnings about type level `:` and `[]` used without backticks.
2. Fix warnings about deprecation of builtin `~` - replaced with `import
Data.Type.Equality ( type (~) )` in the Prelude
3. SemVer is no longer a monoid
4. `path-io` now contains the `AnyPath` instances we were defining
(thanks to Jan) so they can be removed.
5. Added `aeson-better-errors-0.9.1.1` as an extra-dep. The reason it is
not part of the resolver is only because it has a strict bound on base
which is not compatible with ghc 9.4.5. To work around this I've set:

    ```
    allow-newer: true
    allow-newer-deps:
      - aeson-better-errors
    ```
which relaxed the upper constraint bounds for `aeson-better-errors`
only. When the base constraints have been updated we can remove this
workaround.

6. Use stack2cabal to generate the cabal.project file and to freeze
dependency versions.

    https://www.stackage.org/lts-21.6/cabal.config now contains the
constraint `haskeline installed`, which means that the version of
haskeline that is globally installed with GHC 9.4.5 will be used, see:
    * https://github.com/commercialhaskell/stackage/issues/7002
GHC 9.4.5 comes with haskeline 0.8.2 preinstalled but our configuration
contains the source-repository-package for haskeline 0.8.2.1 (required
because we're using a fork) so if you try to run` cabal build` you get a
conflict.

Constraints from cabal imports cannot yet be overridden so it's not
possible to get rid of this conflict using the import method. So we need
to use stack2cabal with an explicit freeze file instead.

7. Remove `runTempFilePure` as this is unused and depends on
`Polysemy.Fresh` in `polysemy-zoo` which is not available in the
resolver. It turns out that it's not possible to use the `Fresh` effect
in a pure context anyway, so it was not possible to use
`runTempFilePure` for its original purpose.

8. We now use https://github.com/benz0li/ghc-musl as the base container
for static linux builds, this means we don't need to maintain our own
Docker container for this purpose.

9. The PR for the nightly builds is ready
https://github.com/anoma/juvix-nightly-builds/pull/2, it should be
merged as soon as this PR is merged.

Thanks to @benz0li for maintaining https://github.com/benz0li/ghc-musl
and (along with @TravisCardwell) for help with building the static
binary.

* Closes https://github.com/anoma/juvix/issues/2166
This commit is contained in:
Paul Cadman 2023-08-11 10:49:33 +01:00 committed by GitHub
parent b5a3b0088e
commit 46ab163ca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 3105 additions and 241 deletions

View File

@ -4,9 +4,9 @@ ARG VARIANT="ubuntu-22.04"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
ENV DEBIAN_FRONTEND=noninteractive
ENV BOOTSTRAP_HASKELL_NONINTERACTIVE=1
ENV BOOTSTRAP_HASKELL_GHC_VERSION=9.2.7
ENV BOOTSTRAP_HASKELL_GHC_VERSION=9.4.5
ENV BOOTSTRAP_HASKELL_CABAL_VERSION=3.10.1.0
ENV BOOTSTRAP_HASKELL_STACK_VERSION=2.9.3
ENV BOOTSTRAP_HASKELL_STACK_VERSION=2.11.1
ENV BOOTSTRAP_HASKELL_INSTALL_STACK=1
ENV BOOTSTRAP_HASKELL_INSTALL_HLS=1

View File

@ -8,11 +8,14 @@ on:
required: true
default: "main"
env:
STACK_VERSION: 2.11.1
jobs:
build:
name: Build static binary
runs-on: ubuntu-latest
container: ghcr.io/paulcadman/ghc-alpine:9.2.7
container: glcr.b-data.ch/ghc/ghc-musl:9.4.5
steps:
- name: checkout code
uses: actions/checkout@v3
@ -28,14 +31,23 @@ jobs:
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
shell: bash
- name: install stack
run: |
curl https://github.com/commercialhaskell/stack/releases/download/v$STACK_VERSION/stack-$STACK_VERSION-linux-x86_64-static.tar.gz -OL
tar xf stack-STACK_VERSION-linux-x86_64-static.tar.gz
cp stack-STACK_VERSION-linux-x86_64-static/stack /usr/local/bin
- name: Stack permissions bug workaround
run: "chown -R $(id -un):$(id -gn) ~"
- name: Install clang14
run: apk add --update clang14
- name: Runtime build
run: make runtime
run: make runtime LIBTOOL=llvm14-ar
- name: build Juvix
run: stack install --allow-different-user --system-ghc --ghc-options='-split-sections -optl-static'
run: stack install --allow-different-user --system-ghc --ghc-options='-split-sections' --flag juvix:static
- run: echo "HOME=$HOME" >> $GITHUB_ENV
shell: bash

View File

@ -105,7 +105,7 @@ getVersion :: forall r. (Members '[Embed IO] r) => Sem r SemVer
getVersion = do
txt <- embed getLine
if
| Text.null txt -> return mempty
| Text.null txt -> return defaultVersion
| otherwise -> case parse semver' txt of
Right r -> return r
Left err -> do

View File

@ -1,25 +1,22 @@
with-compiler: ghc-9.2.7
-- Generated by stack2cabal
with-compiler: ghc-9.4.5
packages:
./
jobs: $ncpus
source-repository-package
type: git
location: https://github.com/janmasrovira/haskeline.git
tag: 81e393e156508a20fcc197acc945b0f44aa4f82b
source-repository-package
type: git
location: https://github.com/janmasrovira/repline.git
tag: a735ab1459db408adda080eb5ea21b96fb4a6011
allow-older: *
allow-newer: *
import: https://www.stackage.org/lts-20.21/cabal.config
package juvix
ghc-options: -optP-Wno-nonportable-include-path
test-show-details: direct
source-repository-package
type: git
location: https://github.com/janmasrovira/repline.git
tag: a735ab1459db408adda080eb5ea21b96fb4a6011
source-repository-package
type: git
location: https://github.com/janmasrovira/haskeline.git
tag: 81e393e156508a20fcc197acc945b0f44aa4f82b

3007
cabal.project.freeze Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +0,0 @@
FROM alpine:3.12
RUN apk upgrade --no-cache &&\
apk add --no-cache curl gcc g++ gmp-dev ncurses-dev libffi-dev make xz gzip tar perl git bash sudo binutils-gold lld &&\
apk add --no-cache zlib zlib-dev zlib-static gmp gmp-dev ncurses-static xz
RUN curl https://downloads.haskell.org/~ghc/8.10-latest/ghc-8.10.2-x86_64-alpine3.10-linux-integer-simple.tar.xz -OL
RUN tar xf ghc-8.10.2-x86_64-alpine3.10-linux-integer-simple.tar.xz
RUN cd ghc-8.10.2-x86_64-unknown-linux && ./configure --prefix /opt && make install
RUN curl https://downloads.haskell.org/~ghc/9.2.5/ghc-9.2.5-src.tar.xz -OL
RUN tar xf ghc-9.2.5-src.tar.xz
WORKDIR /ghc-9.2.5
RUN GHC=/opt/bin/ghc ./configure --prefix /usr/local
RUN make -j
RUN make install
RUN apk add --no-cache clang llvm
WORKDIR /
RUN curl https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-linux-x86_64.tar.gz -OL
RUN tar xf stack-2.9.1-linux-x86_64.tar.gz
RUN cp stack-2.9.1-linux-x86_64/stack /usr/local/bin

View File

@ -1,30 +0,0 @@
FROM alpine:3.12
RUN apk upgrade --no-cache &&\
apk add --no-cache curl gcc g++ gmp-dev ncurses-dev libffi-dev make xz gzip tar perl git bash sudo binutils-gold lld &&\
apk add --no-cache zlib zlib-dev zlib-static gmp gmp-dev ncurses-static xz
RUN curl https://downloads.haskell.org/~ghc/8.10-latest/ghc-8.10.7-x86_64-alpine3.10-linux-integer-simple.tar.xz -OL
RUN tar xf ghc-8.10.7-x86_64-alpine3.10-linux-integer-simple.tar.xz
RUN cd ghc-8.10.7-x86_64-unknown-linux && ./configure --prefix /opt && make install
RUN curl https://downloads.haskell.org/~ghc/9.2.7/ghc-9.2.7-src.tar.xz -OL
RUN tar xf ghc-9.2.7-src.tar.xz
WORKDIR /ghc-9.2.7
RUN GHC=/opt/bin/ghc ./configure --prefix /usr/local
RUN make -j
RUN make install
RUN apk add --no-cache clang llvm
WORKDIR /
RUN curl https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-linux-x86_64.tar.gz -OL
RUN tar xf stack-2.9.1-linux-x86_64.tar.gz
RUN cp stack-2.9.1-linux-x86_64/stack /usr/local/bin

View File

@ -1,46 +0,0 @@
# The GHC alpine image
We need this image to workaround an issue with the official GHC alpine binary,
see https://gitlab.haskell.org/ghc/ghc/-/issues/20266
We use this image to make static linux binaries.
## Building the image
The tag of the image should be prefixed by the location of the GitHub docker
repository that you're pushing to. In this case the repository is `
ghcr.io/paulcadman`.
```shell
docker build -t ghcr.io/paulcadman/ghc-alpine:9.2.7 -f Dockerfile-ghc-alpine-9.2.7 .
```
## Authenticating with the GitHub Docker repository
First create a classic personal access token with `repo` and `write:packages`
permissions.
Consult the GitHub documentation on how to do this:
https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry
Set the token to the variable `CR_PAT` and then authenticate:
```shell
echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin
```
NB: You do not substitue your username for `USERNAME` in the command above.
## Testing the image
```shell
docker run -it --rm ghcr.io/paulcadman/ghc-alpine:9.2.7
```
## Pushing the image
```shell
docker push ghcr.io/paulcadman/ghc-alpine:9.2.7
```

View File

@ -12,13 +12,22 @@ author:
Lukasz Czajka,
Github's contributors,
]
tested-with: ghc == 9.2.7
tested-with: ghc == 9.4.5
homepage: https://juvix.org
bug-reports: https://github.com/anoma/juvix/issues
description: The Juvix compiler
category: Compilers/Interpreters
github: anoma/juvix
flags:
# This flag can only be used in an environment that contains static libraries
# for all dependencies, including libc We use this when doing a static build
# using the ghc-musl alpine container
static:
description: Build static executable
default: false
manual: true
extra-source-files:
- README.md
- assets/css/*.css
@ -32,10 +41,10 @@ extra-source-files:
- runtime/src/vampir/*.pir
dependencies:
- aeson == 2.0.*
- aeson-better-errors == 0.9.*
- aeson == 2.1.*
- ansi-terminal == 0.11.*
- base == 4.16.*
- base == 4.17.*
- blaze-html == 0.9.*
- bytestring == 0.11.*
- containers == 0.6.*
@ -50,14 +59,13 @@ dependencies:
- hashable == 1.4.*
- language-c == 0.9.*
- libyaml == 0.1.*
- megaparsec == 9.2.*
- megaparsec == 9.3.*
- microlens-platform == 0.4.*
- parser-combinators == 1.3.*
- path == 0.9.*
- path-io == 1.7.*
- polysemy == 1.7.*
- path-io == 1.8.*
- polysemy == 1.9.*
- polysemy-plugin == 0.4.*
- polysemy-zoo == 0.8.*
- pretty == 1.1.*
- prettyprinter == 1.7.*
- prettyprinter-ansi-terminal == 1.1.*
@ -66,18 +74,18 @@ dependencies:
- singletons == 3.0.*
- singletons-th == 3.1.*
- Stream == 0.4.*
- template-haskell == 2.18.*
- template-haskell == 2.19.*
- temporary == 1.3.*
- text == 1.2.*
- text == 2.0.*
- th-utilities == 0.2.*
- time == 1.11.*
- time == 1.12.*
- transformers == 0.5.*
- unicode-show == 0.1.*
- uniplate == 1.6.*
- unix-compat == 0.5.*
- unix-compat == 0.7.*
- unordered-containers == 0.2.*
- utf8-string == 1.0.*
- versions == 5.0.*
- versions == 6.0.*
- xdg-basedir == 0.2.*
- yaml == 0.11.*
@ -89,7 +97,7 @@ dependencies:
- pretty-show == 1.10.*
# benchmarks
- criterion == 1.5.*
- criterion == 1.6.*
- statistics == 0.16.*
- shake == 0.19.*
- colour == 2.3.*
@ -147,6 +155,11 @@ executables:
- string-interpolate == 0.3.*
verbatim:
default-language: GHC2021
when:
- condition: flag(static)
ld-options:
- -static
- -pthread
tests:
juvix-test:

View File

@ -47,7 +47,7 @@ runInfoTableBuilder =
. runState emptyBuilderState
. reinterpret interp
where
interp :: InfoTableBuilder m a -> Sem (State BuilderState : r) a
interp :: InfoTableBuilder m a -> Sem (State BuilderState ': r) a
interp = \case
FreshSymbol -> do
s <- get

View File

@ -24,7 +24,7 @@ runCBuilder =
evalState emptyCBuilderState
. reinterpret interp
where
interp :: CBuilder m a -> Sem (State CBuilderState : r) a
interp :: CBuilder m a -> Sem (State CBuilderState ': r) a
interp = \case
FreshLabel -> do
s <- get

View File

@ -35,7 +35,7 @@ re :: forall r a. (Member (Error JuvixError) r) => Sem (Builtins ': r) a -> Sem
re = reinterpret $ \case
GetBuiltinName' i b -> fromMaybeM notDefined (gets (^. builtinsTable . at b))
where
notDefined :: Sem (State BuiltinsState : r) x
notDefined :: Sem (State BuiltinsState ': r) x
notDefined =
throw $
JuvixError
@ -52,7 +52,7 @@ re = reinterpret $ \case
modify (over builtinsNameTable (set (at n) (Just b)))
Just {} -> alreadyDefined
where
alreadyDefined :: Sem (State BuiltinsState : r) x
alreadyDefined :: Sem (State BuiltinsState ': r) x
alreadyDefined =
throw $
JuvixError

View File

@ -525,7 +525,7 @@ instance SingI s => PrettyPrint (Function s) where
SScoped -> ppRightExpression
ppRightExpression ::
(PrettyPrint a, HasAtomicity a, Members [Reader Options, ExactPrint] r) =>
(PrettyPrint a, HasAtomicity a, Members '[Reader Options, ExactPrint] r) =>
Fixity ->
a ->
Sem r ()

View File

@ -474,7 +474,7 @@ lookupQualifiedSymbol sms = do
where
go ::
forall r'.
Members [State ScoperState, State Scope, Output SymbolEntry, Output ModuleSymbolEntry, Output FixitySymbolEntry] r' =>
Members '[State ScoperState, State Scope, Output SymbolEntry, Output ModuleSymbolEntry, Output FixitySymbolEntry] r' =>
([Symbol], Symbol) ->
Sem r' ()
go (path, sym) = do

View File

@ -71,7 +71,7 @@ runInfoTableBuilder tab =
runState tab
. reinterpret interp
where
interp :: InfoTableBuilder m b -> Sem (State InfoTable : r) b
interp :: InfoTableBuilder m b -> Sem (State InfoTable ': r) b
interp = \case
FreshSymbol -> do
s <- get

View File

@ -223,7 +223,7 @@ combineCompiledPatterns ps = go indexedPatterns
-- (wildcard, binder or constructor) introduces an auxiliary binder.
-- The arguments are then compiled recursively using a new CompileState context.
-- The default case points to the next branch pattern.
compilePattern :: forall r. Members [Reader CompileState, Reader CompileStateNode, InfoTableBuilder] r => Int -> Int -> Int -> Pattern -> Sem r CompiledPattern
compilePattern :: forall r. Members '[Reader CompileState, Reader CompileStateNode, InfoTableBuilder] r => Int -> Int -> Int -> Pattern -> Sem r CompiledPattern
compilePattern baseShift branchNum numPatterns = \case
PatWildcard w -> do
auxPatternsNum <- length . filter isAuxiliaryBinder <$> asks (^. compileStateCompiledPattern . compiledPatBinders)

View File

@ -586,7 +586,7 @@ goAxiomInductive a = whenJust (a ^. Internal.axiomBuiltin) builtinInductive
registerInductive (mkIdentIndex (a ^. Internal.axiomName)) info
mapM_ (\ci -> registerConstructor (ci ^. constructorName) ci) ctrs'
fromTopIndex :: Sem (Reader IndexTable : r) a -> Sem r a
fromTopIndex :: Sem (Reader IndexTable ': r) a -> Sem r a
fromTopIndex = runReader initIndexTable
goAxiomDef ::

View File

@ -687,7 +687,7 @@ registerInductiveConstructors indDef = do
goConstructorDef ::
forall r.
Members [Builtins, NameIdGen, Error ScoperError, Reader Pragmas] r =>
Members '[Builtins, NameIdGen, Error ScoperError, Reader Pragmas] r =>
Internal.Expression ->
ConstructorDef 'Scoped ->
Sem r Internal.ConstructorDef
@ -786,7 +786,7 @@ goListPattern l = do
goExpression ::
forall r.
Members [Builtins, NameIdGen, Error ScoperError, Reader Pragmas] r =>
Members '[Builtins, NameIdGen, Error ScoperError, Reader Pragmas] r =>
Expression ->
Sem r Internal.Expression
goExpression = \case

View File

@ -172,7 +172,7 @@ withLocalTypeVar v = withLocalVar v ArityUnit
withLocalVar :: Members '[Reader LocalVars] r => VarName -> Arity -> Sem r a -> Sem r a
withLocalVar v = local . withArity v
withEmptyLocalVars :: Sem (Reader LocalVars : r) a -> Sem r a
withEmptyLocalVars :: Sem (Reader LocalVars ': r) a -> Sem r a
withEmptyLocalVars = runReader emptyLocalVars
arityLet :: (Members '[Reader InfoTable] r) => Let -> Sem r Arity

View File

@ -34,7 +34,7 @@ returnIfReachable n a = do
r <- askIsReachable n
return (guard r $> a)
goModuleNoCache :: forall r. Members [Reader NameDependencyInfo, MCache] r => ModuleIndex -> Sem r Module
goModuleNoCache :: forall r. Members '[Reader NameDependencyInfo, MCache] r => ModuleIndex -> Sem r Module
goModuleNoCache (ModuleIndex m) = do
body' <- goBody (m ^. moduleBody)
return (set moduleBody body' m)
@ -45,10 +45,10 @@ goModuleNoCache (ModuleIndex m) = do
_moduleImports <- mapM goImport (body ^. moduleImports)
return ModuleBody {..}
goModule :: Members [Reader NameDependencyInfo, MCache] r => Module -> Sem r Module
goModule :: Members '[Reader NameDependencyInfo, MCache] r => Module -> Sem r Module
goModule = cacheGet . ModuleIndex
goModuleIndex :: Members [Reader NameDependencyInfo, MCache] r => ModuleIndex -> Sem r ModuleIndex
goModuleIndex :: Members '[Reader NameDependencyInfo, MCache] r => ModuleIndex -> Sem r ModuleIndex
goModuleIndex = fmap ModuleIndex . cacheGet
goStatement :: forall r. Member (Reader NameDependencyInfo) r => Statement -> Sem r (Maybe Statement)
@ -62,7 +62,7 @@ goStatement s = case s of
StatementFunction f -> returnIfReachable (f ^. funDefName) b
StatementInductive f -> returnIfReachable (f ^. inductiveName) b
goImport :: forall r. Members [Reader NameDependencyInfo, MCache] r => Import -> Sem r Import
goImport :: forall r. Members '[Reader NameDependencyInfo, MCache] r => Import -> Sem r Import
goImport i = do
_importModule <- goModuleIndex (i ^. importModule)
return Import {..}

View File

@ -150,7 +150,7 @@ checkInductiveDef InductiveDef {..} = runInferenceDef $ do
}
)
withEmptyVars :: Sem (Reader LocalVars : r) a -> Sem r a
withEmptyVars :: Sem (Reader LocalVars ': r) a -> Sem r a
withEmptyVars = runReader emptyLocalVars
-- TODO should we register functions (type synonyms) first?

View File

@ -68,13 +68,13 @@ runPathResolverArtifacts = runStateLikeArtifacts runPathResolverPipe' artifactRe
runBuiltinsArtifacts :: Members '[Error JuvixError, State Artifacts] r => Sem (Builtins ': r) a -> Sem r a
runBuiltinsArtifacts = runStateLikeArtifacts runBuiltins artifactBuiltins
runParserInfoTableBuilderArtifacts :: Members '[State Artifacts] r => Sem (Concrete.InfoTableBuilder : r) a -> Sem r a
runParserInfoTableBuilderArtifacts :: Members '[State Artifacts] r => Sem (Concrete.InfoTableBuilder ': r) a -> Sem r a
runParserInfoTableBuilderArtifacts = runStateLikeArtifacts Concrete.runParserInfoTableBuilderRepl artifactParsing
runScoperInfoTableBuilderArtifacts :: Members '[State Artifacts] r => Sem (Scoped.InfoTableBuilder : r) a -> Sem r a
runScoperInfoTableBuilderArtifacts :: Members '[State Artifacts] r => Sem (Scoped.InfoTableBuilder ': r) a -> Sem r a
runScoperInfoTableBuilderArtifacts = runStateLikeArtifacts Scoped.runInfoTableBuilderRepl artifactScopeTable
runScoperScopeArtifacts :: Members '[State Artifacts] r => Sem (State S.Scope : r) a -> Sem r a
runScoperScopeArtifacts :: Members '[State Artifacts] r => Sem (State S.Scope ': r) a -> Sem r a
runScoperScopeArtifacts m = do
s <- fromJust <$> gets (^. artifactMainModuleScope)
(s', a) <- runState s m

View File

@ -4,6 +4,7 @@ module Juvix.Compiler.Pipeline.Package
RawPackage,
Package,
Package' (..),
defaultVersion,
defaultStdlibDep,
packageName,
packageBuildDir,
@ -154,7 +155,7 @@ defaultPackageName :: Text
defaultPackageName = "my-project"
defaultVersion :: SemVer
defaultVersion = SemVer 0 0 0 [] Nothing
defaultVersion = SemVer 0 0 0 Nothing Nothing
globalPackage :: Package
globalPackage =

View File

@ -69,14 +69,14 @@ runToInternal ::
Members '[Reader EntryPoint, State Artifacts, Error JuvixError] r =>
Sem
( State Scoper.ScoperState
: FromConcrete.MCache
: Reader Scoper.ScopeParameters
: Reader (HashSet NameId)
: State Scoper.Scope
: Concrete.InfoTableBuilder
: Builtins
: NameIdGen
: r
': FromConcrete.MCache
': Reader Scoper.ScopeParameters
': Reader (HashSet NameId)
': State Scoper.Scope
': Concrete.InfoTableBuilder
': Builtins
': NameIdGen
': r
)
b ->
Sem r b

View File

@ -2,14 +2,11 @@ module Juvix.Data.Effect.Files.Pure where
import Data.HashMap.Strict qualified as HashMap
import Data.Tree
import Data.Unique
import Juvix.Data.Effect.Files.Base
import Juvix.Extra.Version
import Juvix.Prelude.Base
import Juvix.Prelude.Path
import Juvix.Prelude.Prepath
import Polysemy.ConstraintAbsorber.MonadCatch
import Polysemy.Fresh
import System.FilePath qualified as FilePath
import Prelude qualified
@ -112,20 +109,6 @@ canonicalDirPure cwd0 = dotdot . (^. prepath)
juvixConfigDirPure :: Path Abs Dir
juvixConfigDirPure = $(mkAbsDir "/.config/juvix/") <//> versionDir
runTempFilePure ::
Members '[Files, Fresh Unique, Error SomeException] r =>
Sem (TempFile ': r) a ->
Sem r a
runTempFilePure = interpret $ \case
TempFilePath -> do
tmpDir <- absorbMonadThrow (parseAbsDir "/tmp")
uid <- show . hashUnique <$> fresh
tmpFile <- absorbMonadThrow (parseRelFile uid)
let p = tmpDir <//> tmpFile
writeFile' p ""
return p
RemoveTempFile p -> removeFile' p
missingErr :: (Members '[State FS] r) => FilePath -> Sem r a
missingErr f = do
root <- get @FS

View File

@ -104,6 +104,6 @@ runErrorIO =
runErrorIO' ::
(ToGenericError a, Member (Embed IO) r) =>
Sem (Error a : r) b ->
Sem (Error a ': r) b ->
Sem r b
runErrorIO' = runReader defaultGenericOptions . runErrorIO . raiseUnder

View File

@ -6,7 +6,7 @@ module Juvix.Data.Yaml
where
import Data.Aeson.BetterErrors hiding (mapError, (<|>))
import Data.Aeson.Internal (formatError)
import Data.Aeson.Types (formatError)
import Data.Yaml (FromJSON (..), ParseException (..), prettyPrintParseException)
import Data.Yaml.Internal (Warning (..), decodeHelper)
import GHC.IO (unsafePerformIO)

View File

@ -108,7 +108,7 @@ formatProject p = do
subRes <- combineResults <$> mapM format juvixFiles
return (res <> subRes, RecurseFilter (\hasJuvixYaml d -> not hasJuvixYaml && not (isHiddenDirectory d)))
formatPath :: Members [Reader NewSyntax, Reader Text, ScopeEff] r => Path Abs File -> Sem r (NonEmpty AnsiText)
formatPath :: Members '[Reader NewSyntax, Reader Text, ScopeEff] r => Path Abs File -> Sem r (NonEmpty AnsiText)
formatPath p = do
res <- scopeFile p
formatScoperResult res
@ -147,7 +147,7 @@ formatResultFromContents formattedContents filepath = do
)
return res
formatScoperResult :: Members [Reader NewSyntax, Reader Text] r => Scoper.ScoperResult -> Sem r (NonEmpty AnsiText)
formatScoperResult :: Members '[Reader NewSyntax, Reader Text] r => Scoper.ScoperResult -> Sem r (NonEmpty AnsiText)
formatScoperResult res = do
let cs = res ^. Scoper.comments
formattedModules <-
@ -165,7 +165,7 @@ formatScoperResult res = do
Nothing ->
return formattedModules
where
formatTopModule :: Members [Reader NewSyntax, Reader Comments] r => Module 'Scoped 'ModuleTop -> Sem r AnsiText
formatTopModule :: Members '[Reader NewSyntax, Reader Comments] r => Module 'Scoped 'ModuleTop -> Sem r AnsiText
formatTopModule m = do
NewSyntax newSyntax <- ask
cs <- ask

View File

@ -80,6 +80,7 @@ module Juvix.Prelude.Base
IsString (..),
Alternative (..),
MonadIO (..),
type (~),
)
where
@ -142,6 +143,7 @@ import Data.Text.Encoding
import Data.Text.IO
import Data.Traversable
import Data.Tuple.Extra hiding (both)
import Data.Type.Equality (type (~))
import Data.Typeable hiding (TyCon)
import Data.Void
import Data.Word

View File

@ -8,58 +8,9 @@ module Juvix.Prelude.Path.OrphanInstances where
import Juvix.Prelude.Base
import Path
import Path.IO
import Prettyprinter
instance Pretty (Path a b) where
pretty = pretty . toFilePath
deriving stock instance (Data b) => Data (SomeBase b)
instance AnyPath (SomeBase File) where
type AbsPath (SomeBase File) = Path Abs File
type RelPath (SomeBase File) = Path Rel File
canonicalizePath :: (MonadIO m) => SomeBase File -> m (Path Abs File)
canonicalizePath = \case
Abs a -> canonicalizePath a
Rel a -> canonicalizePath a
makeAbsolute :: (MonadIO m) => SomeBase File -> m (Path Abs File)
makeAbsolute = \case
Abs a -> makeAbsolute a
Rel a -> makeAbsolute a
makeRelative :: (MonadThrow m) => Path Abs Dir -> SomeBase File -> m (Path Rel File)
makeRelative r = \case
Abs a -> makeRelative r a
Rel a -> makeRelative r a
makeRelativeToCurrentDir :: (MonadIO m) => SomeBase File -> m (Path Rel File)
makeRelativeToCurrentDir = \case
Abs a -> makeRelativeToCurrentDir a
Rel a -> makeRelativeToCurrentDir a
instance AnyPath (SomeBase Dir) where
type AbsPath (SomeBase Dir) = Path Abs Dir
type RelPath (SomeBase Dir) = Path Rel Dir
canonicalizePath :: (MonadIO m) => SomeBase Dir -> m (Path Abs Dir)
canonicalizePath = \case
Abs a -> canonicalizePath a
Rel a -> canonicalizePath a
makeAbsolute :: (MonadIO m) => SomeBase Dir -> m (Path Abs Dir)
makeAbsolute = \case
Abs a -> makeAbsolute a
Rel a -> makeAbsolute a
makeRelative :: (MonadThrow m) => Path Abs Dir -> SomeBase Dir -> m (Path Rel Dir)
makeRelative r = \case
Abs a -> makeRelative r a
Rel a -> makeRelative r a
makeRelativeToCurrentDir :: (MonadIO m) => SomeBase Dir -> m (Path Rel Dir)
makeRelativeToCurrentDir = \case
Abs a -> makeRelativeToCurrentDir a
Rel a -> makeRelativeToCurrentDir a

View File

@ -1,8 +1,12 @@
ghc-options:
"$locals": -optP-Wno-nonportable-include-path
resolver: lts-20.21
resolver: lts-21.6
extra-deps:
- git: https://github.com/janmasrovira/repline.git
commit: a735ab1459db408adda080eb5ea21b96fb4a6011
- git: https://github.com/janmasrovira/haskeline.git
commit: 81e393e156508a20fcc197acc945b0f44aa4f82b
- aeson-better-errors-0.9.1.1
allow-newer: true
allow-newer-deps:
- aeson-better-errors