Skip to content

Commit 2079bd7

Browse files
nfrisbygeo2a
authored andcommitted
consensus: remove CPP from headerRealPoint
GHC 9.4+ "erroneously" requires HasHeader blk. This patch prevents that. I _think_ the new local signature forces GHC to invoke the HeaderHash (Header blk) ~ HeaderHash blk rewrite _later_, thereby avoiding that undesirable Wanted constraint.
1 parent 5608d79 commit 2079bd7

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Block/Abstract.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ type instance BlockProtocol (Header blk) = BlockProtocol blk
154154

155155
type instance HeaderHash (Header blk) = HeaderHash blk
156156

157-
instance HasHeader blk => StandardHash (Header blk)
157+
instance StandardHash blk => StandardHash (Header blk)
158158

159159
-- | Get the 'HeaderFields' of a block, without requiring 'HasHeader blk'
160160
--

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Block/RealPoint.hs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE CPP #-}
21
{-# LANGUAGE DeriveGeneric #-}
32
{-# LANGUAGE FlexibleContexts #-}
43
{-# LANGUAGE OverloadedStrings #-}
@@ -87,17 +86,15 @@ blockRealPoint blk = RealPoint s h
8786
HeaderFields { headerFieldSlot = s, headerFieldHash = h } = getHeaderFields blk
8887

8988
headerRealPoint ::
90-
( HasHeader (Header blk)
91-
#if __GLASGOW_HASKELL__ >= 904
92-
-- GHC 9.4+ considers these constraints insufficient.
93-
, HasHeader blk
94-
#endif
95-
)
89+
forall blk. HasHeader (Header blk)
9690
=> Header blk
9791
-> RealPoint blk
9892
headerRealPoint hdr = RealPoint s h
9993
where
100-
HeaderFields { headerFieldSlot = s, headerFieldHash = h } = getHeaderFields hdr
94+
HeaderFields { headerFieldSlot = s, headerFieldHash = h } = hf
95+
96+
hf :: HeaderFields (Header blk)
97+
hf = getHeaderFields hdr
10198

10299
realPointToPoint :: RealPoint blk -> Point blk
103100
realPointToPoint (RealPoint s h) = BlockPoint s h

0 commit comments

Comments
 (0)