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 Jun 23, 2023
1 parent 9010b71 commit da7ffa0
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 22 deletions.
24 changes: 22 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ 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-05-10T10:34:57Z
, cardano-haskell-packages 2023-05-24T10:41:02Z
-- Bump this if you need newer packages from Hackage
, hackage.haskell.org 2023-06-21T21:42:02Z
-- Bump this if you need newer packages from CHaP
, cardano-haskell-packages 2023-06-20T22:19:21Z

packages:
cardano-api
Expand All @@ -41,3 +43,21 @@ write-ghc-environment-files: always
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.


if impl(ghc >= 9.6)
allow-newer:
, *:base
, *:ghc-prim
, *:template-haskell

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-consensus
tag: 1e59f219ba765fb97a8e16c500e1f91395bdeaef
--sha256: 1xrnpgrlqwbda3cnj24mzncn3b9hb9ybygn5byhhxgy8ikmqdvfh
subdir:
ouroboros-consensus
ouroboros-consensus-cardano
ouroboros-consensus-protocol
ouroboros-consensus-diffusion
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.18

ghc-options: -Wall
-Wcompat
Expand Down
16 changes: 8 additions & 8 deletions 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 Expand Up @@ -121,7 +121,7 @@ library internal
, cardano-binary
, cardano-crypto
, cardano-crypto-class >= 2.1.1
, cardano-crypto-wrapper ^>= 1.5
, cardano-crypto-wrapper
, cardano-data >= 1.0
, cardano-ledger-alonzo >= 1.1.1
, cardano-ledger-allegra >= 1.1
Expand Down Expand Up @@ -149,7 +149,7 @@ library internal
, microlens
, mtl
, network
, optparse-applicative-fork
, optparse-applicative
, ouroboros-consensus >= 0.7
, ouroboros-consensus-cardano >= 0.6
, ouroboros-consensus-diffusion >= 0.6
Expand All @@ -159,13 +159,13 @@ library internal
, ouroboros-network-framework
, ouroboros-network-protocols
, parsec
, plutus-ledger-api:{plutus-ledger-api, plutus-ledger-api-testlib} ^>=1.5
, plutus-ledger-api:{plutus-ledger-api, plutus-ledger-api-testlib} ^>=1.7
, prettyprinter
, prettyprinter-configurable ^>= 1.1
, prettyprinter-configurable >= 1.1
, random
, scientific
, serialise
, small-steps ^>= 1.0
, small-steps
, stm
, text
, time
Expand Down Expand Up @@ -306,8 +306,8 @@ test-suite cardano-api-golden
, hedgehog
, hedgehog-extras >= 0.4.3.0
, microlens
, plutus-core ^>= 1.5
, plutus-ledger-api ^>= 1.5
, plutus-core
, plutus-ledger-api
, tasty
, tasty-hedgehog
, time
Expand Down
48 changes: 44 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 @@ -95,3 +100,38 @@ checkVrfFilePermissionsImpl (File vrfPrivKey) = do
hasGroupPermissions fm' = fm' `hasPermission` groupModes

#endif

-- | 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
7 changes: 0 additions & 7 deletions cardano-api/internal/Cardano/Api/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
module Cardano.Api.Orphans () where

import Cardano.Binary (DecoderError (..))
import qualified Cardano.Ledger.Alonzo.Scripts as Ledger
import qualified Cardano.Ledger.Crypto as Crypto
import qualified Ouroboros.Consensus.Shelley.Ledger.Query as Consensus

Expand All @@ -17,12 +16,6 @@ import Data.Aeson (ToJSON (..), object, pairs, (.=))
import qualified Data.Aeson as Aeson
import Data.Data (Data)


-- FIXME: A temporary workaround for missing Eq and Data instances in plutus-ledger-api
-- TODO: remove this when plutus-ledger-api gets bumped to >=1.6.1
deriving instance Eq Ledger.CostModelApplyError
deriving instance Data Ledger.CostModelApplyError

deriving instance Data DecoderError
deriving instance Data CBOR.DeserialiseFailure
deriving instance Data Bech32.DecodingError
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/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

0 comments on commit da7ffa0

Please sign in to comment.