Skip to content

Commit

Permalink
Updated Stack setup to LTS 19 (GHC 9.0.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmhat committed Jul 17, 2023
1 parent 959faed commit 6c7f4c7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
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

0 comments on commit 6c7f4c7

Please sign in to comment.