Skip to content

Commit

Permalink
Make it build with ghc-9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
erikd committed Jul 13, 2023
1 parent a6f40d5 commit ccd4b1a
Show file tree
Hide file tree
Showing 22 changed files with 79 additions and 9 deletions.
12 changes: 10 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repository cardano-haskell-packages
-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them
index-state:
, hackage.haskell.org 2023-07-03T00:00:00Z
, cardano-haskell-packages 2023-07-07T22:30:00Z
, hackage.haskell.org 2023-07-10T22:41:49Z
, cardano-haskell-packages 2023-07-12T13:59:36Z

packages:
cardano-api
Expand All @@ -38,6 +38,14 @@ test-show-details: direct
-- Always write GHC env files, because they are needed for ghci.
write-ghc-environment-files: always

if impl(ghc >= 9.6)
allow-newer:
-- Only really needed because `cardano-ledger-byron-test` has not yet been released to CHaP
-- and its not possible to specify `cardano-ledger-byron-test:base` because the dependencies
-- of `cardano-ledger-byron-test` also do not permit the version of `base` that `ghc-9.6`
-- provides.
, *:base

-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.
2 changes: 1 addition & 1 deletion cardano-api-gen/cardano-api-gen.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extra-source-files: README.md, CHANGELOG.md
common project-config
default-language: Haskell2010
default-extensions: OverloadedStrings
build-depends: base >= 4.14 && < 4.17
build-depends: base >= 4.14 && < 4.19

ghc-options: -Wall
-Wcompat
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extra-doc-files: README.md, CHANGELOG.md
common project-config
default-language: Haskell2010
default-extensions: OverloadedStrings
build-depends: base >= 4.14 && < 4.17
build-depends: base >= 4.14 && < 4.19

ghc-options: -Wall
-Wcompat
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}

-- | Blocks in the blockchain
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Certificate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

-- | Certificates embedded in transactions
--
Expand Down
3 changes: 2 additions & 1 deletion cardano-api/internal/Cardano/Api/Eras.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE TypeOperators #-}


-- | Cardano eras, sometimes we have to distinguish them.
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Fees.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

module Cardano.Api.Governance.Actions.ProposalProcedure where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

module Cardano.Api.Governance.Actions.VotingProcedure where
Expand Down
47 changes: 43 additions & 4 deletions cardano-api/internal/Cardano/Api/IO/Compat/Posix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ import System.FilePath ((</>))
import qualified System.IO as IO
import System.IO (Handle)
import System.Posix.Files (fileMode, getFileStatus, groupModes, intersectFileModes,
nullFileMode, otherModes, ownerModes, ownerReadMode, setFdOwnerAndGroup,
setFileMode)
nullFileMode, otherModes, ownerReadMode, setFdOwnerAndGroup, setFileMode,
stdFileMode)
# if MIN_VERSION_unix(2,8,0)
import System.Posix.IO (OpenFileFlags (..), OpenMode (..), closeFd, defaultFileFlags,
fdToHandle, openFd)
#else
import System.Posix.IO (OpenMode (..), closeFd, defaultFileFlags, fdToHandle, openFd)
import System.Posix.Types (FileMode)
#endif
import System.Posix.Types (Fd, FileMode)
import System.Posix.User (getRealUserID)
import Text.Printf (printf)

Expand All @@ -52,7 +57,7 @@ handleFileForWritingWithOwnerPermissionImpl path f = do
-- it will be immediately turned into a Handle (which will be closed when
-- the Handle is closed)
bracketOnError
(openFd path WriteOnly (Just ownerModes) defaultFileFlags)
(openFileDescriptor path WriteOnly)
closeFd
(\fd -> setFdOwnerAndGroup fd user (-1) >> pure fd)
case ownedFile of
Expand Down Expand Up @@ -94,4 +99,38 @@ checkVrfFilePermissionsImpl (File vrfPrivKey) = do
hasGroupPermissions :: FileMode -> Bool
hasGroupPermissions fm' = fm' `hasPermission` groupModes

-- | Opens a file from disk.
openFileDescriptor :: FilePath -> OpenMode -> IO Fd
# if MIN_VERSION_unix(2,8,0)
openFileDescriptor fp openMode =
openFd fp openMode fileFlags
where
fileFlags =
case openMode of
ReadOnly ->
defaultFileFlags
ReadWrite ->
defaultFileFlags { creat = Just stdFileMode }
WriteOnly ->
defaultFileFlags { creat = Just stdFileMode }

# else
openFileDescriptor fp openMode =
openFd fp openMode fMode fileFlags
where
(fMode, fileFlags) =
case openMode of
ReadOnly ->
( Nothing
, defaultFileFlags
)
ReadWrite ->
( Just stdFileMode
, defaultFileFlags
)
WriteOnly ->
( Just stdFileMode
, defaultFileFlags
)
# endif
#endif
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/InMode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}

-- | Transactions in the context of a consensus mode, and other types used in
-- the transaction submission protocol.
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/LedgerEvent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/LedgerState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

{- HLINT ignore "Redundant fmap" -}

Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

{- HLINT ignore "Redundant ==" -}

Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

-- The Shelley ledger uses promoted data kinds which we have to use, but we do
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

{- HLINT ignore "Avoid lambda using `infix`" -}
{- HLINT ignore "Use section" -}
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}

-- The Shelley ledger uses promoted data kinds which we have to use, but we do
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}

{- HLINT ignore "Avoid lambda using `infix`" -}
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

#if !defined(mingw32_HOST_OS)
#define UNIX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-orphans #-}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}

{-# OPTIONS_GHC -Wno-orphans #-}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}

module Test.Cardano.Api.Typed.RawBytes
Expand Down Expand Up @@ -84,7 +85,12 @@ roundtrip_raw_bytes asType g =
H.tripping v serialiseToRawBytes (deserialiseFromRawBytes asType)

roundtrip_verification_key_hash_raw
#if __GLASGOW_HASKELL__ < 906
:: (Key keyrole, Eq (Hash keyrole), Show (Hash keyrole))
#else
-- GHC 9.6 needs an extra constraint.
:: (Key keyrole, Eq (Hash keyrole), Show (Hash keyrole), HasTypeProxy keyrole)
#endif
=> AsType keyrole -> Property
roundtrip_verification_key_hash_raw roletoken =
H.property $ do
Expand Down

0 comments on commit ccd4b1a

Please sign in to comment.