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

Port to GHC-9.8.2 (missing: dhall-{lsp-server,nix,nixpkgs}) #2584

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion dhall-csv/dhall-csv.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Library
Hs-Source-Dirs: src
Build-Depends:
base >= 4.12.0.0 && < 5 ,
bytestring < 0.12,
bytestring < 0.13,
cassava >= 0.5.0.0 && < 0.6 ,
containers >= 0.5.9 && < 0.7 ,
either ,
Expand Down
3 changes: 2 additions & 1 deletion dhall-csv/src/Dhall/CsvToDhall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ import Prettyprinter (Pretty)

import qualified Data.Csv
import qualified Data.HashMap.Strict as HashMap
import qualified Data.List.NonEmpty as NonEmpty
import qualified Data.Sequence as Sequence
import qualified Data.Text
import qualified Dhall.Core as Core
Expand Down Expand Up @@ -273,7 +274,7 @@ dhallFromCsv Conversion{..} typeExpr = listConvert (Core.normalize typeExpr)
recordConvert (Core.Record record) csvRecord
| badKeys <- lefts (map decodeUtf8' (HashMap.keys csvRecord))
, not (null badKeys)
= Left $ UnicodeError (head badKeys) -- Only report first key that failed to be decoded
= Left $ UnicodeError (NonEmpty.head . NonEmpty.fromList $ badKeys) -- Only report first key that failed to be decoded
| extraKeys <- (map decodeUtf8 $ HashMap.keys csvRecord) \\ Map.keys record
, strictRecs && not (null extraKeys)
= Left $ UnhandledFields extraKeys
Expand Down
3 changes: 2 additions & 1 deletion dhall-docs/src/Dhall/Docs/CodeRenderer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import Text.Megaparsec.Pos (SourcePos (..))

import qualified Control.Monad.Trans.Writer.Strict as Writer
import qualified Data.List
import qualified Data.List.NonEmpty as NonEmpty
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import qualified Data.Text as Text
Expand Down Expand Up @@ -374,7 +375,7 @@ renderCodeWithHyperLinks contents expr = pre_ $ go (1, 1) lines_ imports

-- calls to `head` and `last` here should never fail since `importLines`
-- have at least one element
let (firstImportLine, lastImportLine) = (head importLines, last importLines)
let (firstImportLine, lastImportLine) = (NonEmpty.head . NonEmpty.fromList $ importLines, last importLines)
let prefixCols = Text.take (importStartCol - currCol) firstImportLine
let suffixCols = Text.drop (importEndCol - currCol) lastImportLine

Expand Down
2 changes: 1 addition & 1 deletion dhall-docs/src/Dhall/Docs/Comment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ parseDhallDocsText (BlockComment blockComment) =
Just e -> DhallDocsText e
where
joinedText = Data.Text.strip $ Data.Text.unlines reIndentedLines
commentLines = tail $ Data.Text.lines blockComment
commentLines = NonEmpty.tail $ NonEmpty.fromList $ Data.Text.lines blockComment

leadingSpaces = Data.Text.takeWhile isSpace
where
Expand Down
2 changes: 1 addition & 1 deletion dhall-json/dhall-json.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Library
Hs-Source-Dirs: src
Build-Depends:
base >= 4.11.0.0 && < 5 ,
aeson >= 1.4.6.0 && < 2.2 ,
aeson >= 1.4.6.0 && < 2.3 ,
aeson-pretty >= 0.8.0 && < 0.9 ,
aeson-yaml >= 1.1.0 && < 1.2 ,
bytestring < 0.13,
Expand Down
2 changes: 1 addition & 1 deletion dhall-lsp-server/dhall-lsp-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ library
src
default-extensions: RecordWildCards OverloadedStrings
build-depends:
aeson >= 1.3.1.1 && < 2.2
aeson >= 1.3.1.1 && < 2.3
, aeson-pretty >= 0.8.7 && < 0.9
, base >= 4.11 && < 5
, bytestring >= 0.10.8.2 && < 0.12
Expand Down
2 changes: 1 addition & 1 deletion dhall-openapi/dhall-openapi.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Library
Ghc-Options: -Wall
Build-Depends:
base >= 4.11.0.0 && < 5 ,
aeson >= 1.0.0.0 && < 2.2 ,
aeson >= 1.0.0.0 && < 2.3 ,
containers >= 0.5.8.0 && < 0.7 ,
dhall >= 1.38.0 && < 1.43 ,
prettyprinter >= 1.7.0 && < 1.8 ,
Expand Down
23 changes: 12 additions & 11 deletions dhall-openapi/src/Dhall/Kubernetes/Convert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ import Data.Text (Text)
import Dhall.Kubernetes.Types
import GHC.Generics (Generic, Rep)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Data.Map
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import qualified Data.Sort as Sort
import qualified Data.Text as Text
import qualified Data.Tuple as Tuple
import qualified Dhall.Core as Dhall
import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.List.NonEmpty as NonEmpty
import qualified Data.Map.Strict as Data.Map
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import qualified Data.Sort as Sort
import qualified Data.Text as Text
import qualified Data.Tuple as Tuple
import qualified Dhall.Core as Dhall
import qualified Dhall.Map
import qualified Dhall.Optics
import qualified Data.Map as Map
Expand Down Expand Up @@ -112,7 +113,7 @@ mkImport :: Data.Map.Map Prefix Dhall.Import -> [Text] -> Text -> Dhall.Import
mkImport prefixMap components file =
case Data.Map.toList filteredPrefixMap of
[] -> localImport
xs -> (snd . head $ Sort.sortOn (Text.length . fst) xs) <> localImport
xs -> (snd . NonEmpty.head . NonEmpty.fromList $ Sort.sortOn (Text.length . fst) xs) <> localImport
where
localImport = Dhall.Import{..}
importMode = Dhall.Code
Expand Down Expand Up @@ -206,7 +207,7 @@ toTypes' prefixMap typeSplitter preferNaturalInt natIntExceptions definitions to
case hierarchy of
[] -> ""
[ModelName{..}] -> Text.unpack (last $ Text.splitOn "." unModelName)
_ -> getModelName (tail hierarchy)
_ -> getModelName (NonEmpty.tail . NonEmpty.fromList $ hierarchy)

convertAndAccumWithKey :: ModelHierarchy -> Data.Map.Map ModelName Definition -> ModelName -> Definition -> (Data.Map.Map ModelName Definition, Expr)
convertAndAccumWithKey modelHierarchy accDefs k v = (mergeNoConflicts equalsIgnoringDescription accDefs leftOverDefs, expr)
Expand Down
18 changes: 11 additions & 7 deletions dhall-openapi/src/Dhall/Kubernetes/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,14 @@ data BaseData = BaseData
} deriving (Generic, Show, Eq)

instance FromJSON BaseData where
parseJSON = withArray "array of values" $ \arr -> withObject "baseData" (\o -> do
group <- o .:? "group" .!= ""
kind <- o .: "kind"
version <- o .: "version"
let apiVersion = (if Text.null group then "" else group <> "/") <> version
pure BaseData{..})
(head $ Vector.toList arr)
parseJSON = withArray "array of values" $ \arr -> do
case Vector.toList arr of
[] -> fail "missing baseData object in array"
(item:_) ->
withObject "baseData" (\o -> do
group <- o .:? "group" .!= ""
kind <- o .: "kind"
version <- o .: "version"
let apiVersion = (if Text.null group then "" else group <> "/") <> version
pure BaseData{..})
item
2 changes: 1 addition & 1 deletion dhall-yaml/dhall-yaml.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Library
HsYAML >= 0.2 && < 0.3 ,
HsYAML-aeson >= 0.2 && < 0.3 ,
base >= 4.11.0.0 && < 5 ,
aeson >= 1.0.0.0 && < 2.2 ,
aeson >= 1.0.0.0 && < 2.3 ,
bytestring < 0.13,
dhall >= 1.31.0 && < 1.43,
dhall-json >= 1.6.0 && < 1.8 ,
Expand Down
2 changes: 1 addition & 1 deletion dhall/dhall.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ Common common
dotgen >= 0.4.2 && < 0.5 ,
either >= 5 && < 5.1,
exceptions >= 0.8.3 && < 0.11,
filepath >= 1.4 && < 1.5 ,
filepath >= 1.4 && < 1.6 ,
half >= 0.2.2.3 && < 0.4 ,
haskeline >= 0.7.2.1 && < 0.9 ,
hashable >= 1.2 && < 1.5 ,
Expand Down
5 changes: 5 additions & 0 deletions dhall/src/Dhall/Import/Headers.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ViewPatterns #-}
Expand All @@ -9,7 +10,11 @@ module Dhall.Import.Headers
, toOriginHeaders
) where

#if (MIN_VERSION_base(4,19,0))
import Control.Applicative (Alternative (..))
#else
import Control.Applicative (Alternative (..), liftA2)
#endif
import Control.Exception (SomeException)
import Control.Monad.Catch (handle, throwM)
import Data.Text (Text)
Expand Down
64 changes: 39 additions & 25 deletions dhall/src/Dhall/Marshal/Decode.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DerivingStrategies #-}
Expand Down Expand Up @@ -135,7 +136,11 @@ module Dhall.Marshal.Decode
) where


#if (MIN_VERSION_base(4,19,0))
import Control.Applicative (empty)
#else
import Control.Applicative (empty, liftA2)
#endif
import Control.Exception (Exception)
import Control.Monad (guard)
import Control.Monad.Trans.State.Strict
Expand Down Expand Up @@ -1291,14 +1296,19 @@ setHelper size toSet (Decoder extractIn expectedIn) = Decoder extractOut expecte
vSet = toSet vList
sameSize = size vSet == Data.Sequence.length vSeq
duplicates = vList List.\\ Data.Foldable.toList vSet
err | length duplicates == 1 =
err =
case duplicates of
(duplicate : []) ->
"One duplicate element in the list: "
<> (Data.Text.pack $ show $ head duplicates)
| otherwise = Data.Text.pack $ unwords
<> (Data.Text.pack $ show duplicate)
(duplicate : _) ->
Data.Text.pack $ unwords
[ show $ length duplicates
, "duplicates were found in the list, including"
, show $ head duplicates
, show duplicate
]
([]) ->
"No duplicate (code branch assumed to be unreachable)."
Failure f -> Failure f
extractOut expr = typeError expectedOut expr

Expand Down Expand Up @@ -1605,13 +1615,15 @@ instance (Pretty s, Pretty a, Typeable s, Typeable a) => Show (ExtractError s a)
show (TypeMismatch e) = show e
show (ExpectedTypeError e) = show e
show (ExtractError es) =
_ERROR <> ": Failed extraction \n\
\ \n\
\The expression type-checked successfully but the transformation to the target \n\
\type failed with the following error: \n\
\ \n\
\" <> Data.Text.unpack es <> "\n\
\ \n"
unlines
[ _ERROR <> ": Failed extraction "
, " "
, "The expression type-checked successfully but the transformation to the target "
, "type failed with the following error: "
, " "
, Data.Text.unpack es
, " "
]

instance (Pretty s, Pretty a, Typeable s, Typeable a) => Exception (ExtractError s a)

Expand Down Expand Up @@ -1670,20 +1682,22 @@ instance (Pretty s, Typeable s, Pretty a, Typeable a) => Exception (InvalidDecod

instance (Pretty s, Pretty a, Typeable s, Typeable a) => Show (InvalidDecoder s a) where
show InvalidDecoder { .. } =
_ERROR <> ": Invalid Dhall.Decoder \n\
\ \n\
\Every Decoder must provide an extract function that does not fail with a type \n\
\error if an expression matches the expected type. You provided a Decoder that \n\
\disobeys this contract \n\
\ \n\
\The Decoder provided has the expected dhall type: \n\
\ \n\
\" <> show txt0 <> "\n\
\ \n\
\and it threw a type error during extraction from the well-typed expression: \n\
\ \n\
\" <> show txt1 <> "\n\
\ \n"
unlines
[ _ERROR <> ": Invalid Dhall.Decoder "
, " "
, "Every Decoder must provide an extract function that does not fail with a type "
, "error if an expression matches the expected type. You provided a Decoder that "
, "disobeys this contract "
, " "
, "The Decoder provided has the expected dhall type: "
, " "
, show txt0
, " "
, "and it threw a type error during extraction from the well-typed expression: "
, " "
, show txt1
, " "
]
where
txt0 = Dhall.Util.insert invalidDecoderExpected
txt1 = Dhall.Util.insert invalidDecoderExpression
Expand Down
8 changes: 8 additions & 0 deletions dhall/src/Dhall/Parser/Combinators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ module Dhall.Parser.Combinators
) where


#if (MIN_VERSION_base(4,19,0))
import Control.Applicative (Alternative (..))
#else
import Control.Applicative (Alternative (..), liftA2)
#endif
import Control.Exception (Exception)
import Control.Monad (MonadPlus (..))
import Data.String (IsString (..))
Expand Down Expand Up @@ -169,6 +173,10 @@ instance Text.Megaparsec.MonadParsec Void Text Parser where

updateParserState f = Parser (Text.Megaparsec.updateParserState f)

#if (MIN_VERSION_megaparsec(9,4,0))
mkParsec f = Parser (Text.Megaparsec.mkParsec f)
#endif

instance Semigroup a => Semigroup (Parser a) where
(<>) = liftA2 (<>)

Expand Down
5 changes: 5 additions & 0 deletions dhall/src/Dhall/Parser/Expression.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
Expand All @@ -7,7 +8,11 @@
-- | Parsing Dhall expressions.
module Dhall.Parser.Expression where

#if (MIN_VERSION_base(4,19,0))
import Control.Applicative (Alternative (..), optional)
#else
import Control.Applicative (Alternative (..), liftA2, optional)
#endif
import Data.Foldable (foldl')
import Data.List.NonEmpty (NonEmpty (..))
import Data.Text (Text)
Expand Down
5 changes: 3 additions & 2 deletions dhall/src/Dhall/Tags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Dhall.Tags
) where

import Control.Exception (SomeException (..), handle)
import Data.List (foldl', isSuffixOf)
import Data.List (foldl', isPrefixOf, isSuffixOf)
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import Data.Text.Encoding (encodeUtf8)
Expand Down Expand Up @@ -261,9 +261,10 @@ inputToFiles followSyms suffixes (InputFile path) = go path
then return []
else do
-- filter . .. and hidden files .*
contents <- fmap (filter ((/=) '.' . head))
contents <- fmap (filter (not . isHiddenOrSpecialDirectoryLinkName))
(SD.getDirectoryContents p)
concat <$> mapM (go . (</>) p) contents
else return [p | matchingSuffix || p == path]
where matchingSuffix = maybe True (any (`isSuffixOf` p)) suffixes
isSymLink = SD.pathIsSymbolicLink p
isHiddenOrSpecialDirectoryLinkName filename = "." `isPrefixOf` filename
Loading