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

Update Stack setup to LTS 19 (GHC 9.0.2) #2524

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ jobs:
runs-on: ${{ matrix.os.runner }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true
- id: setup-haskell-cabal
name: "Setup Haskell environment"
uses: haskell/actions/setup@v1.2.1
uses: haskell/actions/setup@v2
with:
enable-stack: true
- name: "Cache"
uses: actions/cache@v2
uses: actions/cache@v3
with:
key: ${{ matrix.os.runner }}-${{ hashFiles('stack.yaml') }}-${{ env.cache_generation }}
restore-keys: |
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
package 'dhall-toml' "bin/dhall-to-toml${exe}" "bin/toml-to-dhall${exe}"
package 'dhall-yaml' "bin/dhall-to-yaml-ng${exe}" "bin/yaml-to-dhall${exe}"
- name: "Upload package"
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: 'dhall-${{runner.os}}.${{matrix.os.file-extension}}'
path: 'dhall-*${{runner.os}}.${{matrix.os.file-extension}}'
27 changes: 17 additions & 10 deletions dhall/src/Dhall/TH.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
Expand Down Expand Up @@ -60,7 +61,7 @@ import qualified Numeric.Natural
import qualified Prettyprinter.Render.String as Pretty
import qualified System.IO


{-| This fully resolves, type checks, and normalizes the expression, so the
resulting AST is self-contained.

Expand Down Expand Up @@ -160,9 +161,9 @@ toNestedHaskellType typeParams haskellTypes = loop
, " \n"
, "... which did not fit any of the above criteria."
]

message dhallType = Pretty.renderString (Dhall.Pretty.layout (document dhallType))

loop dhallType = case dhallType of
Bool ->
return (ConT ''Bool)
Expand Down Expand Up @@ -203,7 +204,7 @@ toNestedHaskellType typeParams haskellTypes = loop
haskellElementType <- loop dhallElementType

return (AppT haskellAppType haskellElementType)

Var v
| Just (V param index) <- List.find (v ==) typeParams -> do
let name = Syntax.mkName $ (Text.unpack param) ++ (show index)
Expand Down Expand Up @@ -255,15 +256,21 @@ toDeclaration generateOptions@GenerateOptions{..} haskellTypes typ =
MultipleConstructors{..} -> uncurry (fromMulti typeName) $ getTypeParams code
where
getTypeParams = first numberConsecutive . getTypeParams_ []

getTypeParams_ acc (Lam _ (FunctionBinding _ v _ _ _) rest) = getTypeParams_ (v:acc) rest
getTypeParams_ acc rest = (acc, rest)

derivingClauses = [ derivingGenericClause | generateFromDhallInstance || generateToDhallInstance ]

interpretOptions = generateToInterpretOptions generateOptions typ

toTypeVar (V n i) = Syntax.PlainTV $ Syntax.mkName (Text.unpack n ++ show i)
#if MIN_VERSION_template_haskell(2,17,0)
toTypeVar :: Var -> Syntax.TyVarBndr ()
toTypeVar (V n i) = Syntax.PlainTV (Syntax.mkName (Text.unpack n ++ show i)) ()
#else
toTypeVar :: Var -> Syntax.TyVarBndr
toTypeVar (V n i) = Syntax.PlainTV (Syntax.mkName (Text.unpack n ++ show i))
#endif

toDataD typeName typeParams constructors = do
let name = Syntax.mkName (Text.unpack typeName)
Expand All @@ -277,16 +284,16 @@ toDeclaration generateOptions@GenerateOptions{..} haskellTypes typ =

fromSingle typeName constructorName typeParams dhallType = do
constructor <- toConstructor typeParams generateOptions haskellTypes typeName (constructorName, Just dhallType)

toDataD typeName typeParams [constructor]

fromMulti typeName typeParams dhallType = case dhallType of
Union kts -> do
constructors <- traverse (toConstructor typeParams generateOptions haskellTypes typeName) (Dhall.Map.toList kts)

toDataD typeName typeParams constructors
_ -> fail $ message dhallType

_ -> fail $ message dhallType

message dhallType = Pretty.renderString (Dhall.Pretty.layout $ document dhallType)

Expand Down
14 changes: 7 additions & 7 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-18.18
resolver: lts-19.33
packages:
- dhall
- dhall-bash
Expand All @@ -11,12 +11,12 @@ packages:
- dhall-toml
- dhall-yaml
extra-deps:
- hnix-0.16.0
- hnix-store-core-0.5.0.0
- hnix-store-remote-0.5.0.0
- lucid-2.11.0
- relude-1.0.0.1@sha256:35bcdaf14018e79f11e712b0e2314c1aac79976f28f4adc179985457493557d5,11569
- semialign-1.2@sha256:9afb6eb7e50db7ca34d7c4108aec0f643dae2caaaa80394b44ffdd643315685c,2721
- github: haskell-nix/hnix
commit: 2adbc502e62e755ca0372c913e6278ebe564d7d2
- hnix-store-core-0.6.1.0
- hnix-store-remote-0.6.0.0
- tomland-1.3.3.2
- validation-selective-0.1.0.2
nix:
packages:
- ncurses
Expand Down