git.iko.soy/typeable/nixpkgs
on master help sign in
tamarin-prover: fix ghc 8.4 build (#46597)

See https://hydra.nixos.org/build/81125645 `tamarin-prover' upstream has a patch to fix GHC 8.4 compilation (and uses stack lts-12.1 now), but it's not released yet: https://github.com/tamarin-prover/tamarin-prover/commit/a08f6e400772899b9b0fc16befc50391cd70696b The build is divided in several derivations, therefore the patch had to be splitted and rebased for `lib/term', `lib/theory' and `lib/utils' to ensure that the patch applies properly during the `patchPhase'. Addresses #45960

commit2cfc0bb7ee6200584c89ab46daf04daa9c536e81 authorMaximilian Bosch <maximilian@mbosch.me> dateThu 13 Sep 2018, 14:11 (8 years ago) parente2df8e7
4 files changed+385−3
pkgs/applications/science/logic/tamarin-prover/default.nix+6−3 pkgs/applications/science/logic/tamarin-prover/ghc-8.4-support-term.patch+109 pkgs/applications/science/logic/tamarin-prover/ghc-8.4-support-theory.patch+130 pkgs/applications/science/logic/tamarin-prover/ghc-8.4-support-utils.patch+140
pkgs/applications/science/logic/tamarin-prover/default.nix+6−3
@@ -31,7 +31,8 @@ let
3131 '';
3232
3333 tamarin-prover-utils = mkDerivation (common "tamarin-prover-utils" (src + "/lib/utils") // {
34− patchPhase = replaceSymlinks;
34+ postPatch = replaceSymlinks;
35+ patches = [ ./ghc-8.4-support-utils.patch ];
3536 libraryHaskellDepends = with haskellPackages; [
3637 base base64-bytestring binary blaze-builder bytestring containers
3738 deepseq dlist fclabels mtl pretty safe SHA syb time transformers
@@ -39,7 +40,8 @@ let
3940 });
4041
4142 tamarin-prover-term = mkDerivation (common "tamarin-prover-term" (src + "/lib/term") // {
42− patchPhase = replaceSymlinks;
43+ postPatch = replaceSymlinks;
44+ patches = [ ./ghc-8.4-support-term.patch ];
4345 libraryHaskellDepends = (with haskellPackages; [
4446 attoparsec base binary bytestring containers deepseq dlist HUnit
4547 mtl process safe
@@ -47,7 +49,8 @@ let
4749 });
4850
4951 tamarin-prover-theory = mkDerivation (common "tamarin-prover-theory" (src + "/lib/theory") // {
50− patchPhase = replaceSymlinks;
52+ postPatch = replaceSymlinks;
53+ patches = [ ./ghc-8.4-support-theory.patch ];
5154 doHaddock = false; # broken
5255 libraryHaskellDepends = (with haskellPackages; [
5356 aeson aeson-pretty base binary bytestring containers deepseq dlist
pkgs/applications/science/logic/tamarin-prover/ghc-8.4-support-term.patchnew file+109
@@ -0,0 +1,109 @@
1+From a08f6e400772899b9b0fc16befc50391cd70696b Mon Sep 17 00:00:00 2001
2+From: Felix Yan <felixonmars@archlinux.org>
3+Date: Fri, 18 May 2018 16:24:41 +0800
4+Subject: [PATCH] GHC 8.4 support
5+
6+---
7+ src/Term/Maude/Signature.hs | 8 ++--
8+ src/Term/Rewriting/Definitions.hs | 23 ++++++----
9+ src/Term/Unification.hs | 4 +-
10+ 11 files changed, 79 insertions(+), 48 deletions(-)
11+
12+diff --git a/src/Term/Maude/Signature.hs b/src/Term/Maude/Signature.hs
13+index 98c25d9f..1a4ce82f 100644
14+--- a/src/Term/Maude/Signature.hs
15++++ b/src/Term/Maude/Signature.hs
16+@@ -104,9 +104,9 @@ maudeSig msig@(MaudeSig {enableDH,enableBP,enableMSet,enableXor,enableDiff=_,stF
17+ `S.union` dhReducibleFunSig `S.union` bpReducibleFunSig `S.union` xorReducibleFunSig
18+
19+ -- | A monoid instance to combine maude signatures.
20+-instance Monoid MaudeSig where
21+- (MaudeSig dh1 bp1 mset1 xor1 diff1 stFunSyms1 stRules1 _ _) `mappend`
22+- (MaudeSig dh2 bp2 mset2 xor2 diff2 stFunSyms2 stRules2 _ _) =
23++instance Semigroup MaudeSig where
24++ MaudeSig dh1 bp1 mset1 xor1 diff1 stFunSyms1 stRules1 _ _ <>
25++ MaudeSig dh2 bp2 mset2 xor2 diff2 stFunSyms2 stRules2 _ _ =
26+ maudeSig (mempty {enableDH=dh1||dh2
27+ ,enableBP=bp1||bp2
28+ ,enableMSet=mset1||mset2
29+@@ -114,6 +114,8 @@ instance Monoid MaudeSig where
30+ ,enableDiff=diff1||diff2
31+ ,stFunSyms=S.union stFunSyms1 stFunSyms2
32+ ,stRules=S.union stRules1 stRules2})
33++
34++instance Monoid MaudeSig where
35+ mempty = MaudeSig False False False False False S.empty S.empty S.empty S.empty
36+
37+ -- | Non-AC function symbols.
38+diff --git a/src/Term/Rewriting/Definitions.hs b/src/Term/Rewriting/Definitions.hs
39+index bd942b6a..18562e4e 100644
40+--- a/src/Term/Rewriting/Definitions.hs
41++++ b/src/Term/Rewriting/Definitions.hs
42+@@ -44,10 +44,12 @@ evalEqual (Equal l r) = l == r
43+ instance Functor Equal where
44+ fmap f (Equal lhs rhs) = Equal (f lhs) (f rhs)
45+
46++instance Semigroup a => Semigroup (Equal a) where
47++ (Equal l1 r1) <> (Equal l2 r2) =
48++ Equal (l1 <> l2) (r1 <> r2)
49++
50+ instance Monoid a => Monoid (Equal a) where
51+ mempty = Equal mempty mempty
52+- (Equal l1 r1) `mappend` (Equal l2 r2) =
53+- Equal (l1 `mappend` l2) (r1 `mappend` r2)
54+
55+ instance Foldable Equal where
56+ foldMap f (Equal l r) = f l `mappend` f r
57+@@ -104,14 +106,15 @@ instance Functor Match where
58+ fmap _ NoMatch = NoMatch
59+ fmap f (DelayedMatches ms) = DelayedMatches (fmap (f *** f) ms)
60+
61++instance Semigroup (Match a) where
62++ NoMatch <> _ = NoMatch
63++ _ <> NoMatch = NoMatch
64++ DelayedMatches ms1 <> DelayedMatches ms2 =
65++ DelayedMatches (ms1 <> ms2)
66++
67+ instance Monoid (Match a) where
68+ mempty = DelayedMatches []
69+
70+- NoMatch `mappend` _ = NoMatch
71+- _ `mappend` NoMatch = NoMatch
72+- DelayedMatches ms1 `mappend` DelayedMatches ms2 =
73+- DelayedMatches (ms1 `mappend` ms2)
74+-
75+
76+ instance Foldable Match where
77+ foldMap _ NoMatch = mempty
78+@@ -136,10 +139,12 @@ data RRule a = RRule a a
79+ instance Functor RRule where
80+ fmap f (RRule lhs rhs) = RRule (f lhs) (f rhs)
81+
82++instance Monoid a => Semigroup (RRule a) where
83++ (RRule l1 r1) <> (RRule l2 r2) =
84++ RRule (l1 <> l2) (r1 <> r2)
85++
86+ instance Monoid a => Monoid (RRule a) where
87+ mempty = RRule mempty mempty
88+- (RRule l1 r1) `mappend` (RRule l2 r2) =
89+- RRule (l1 `mappend` l2) (r1 `mappend` r2)
90+
91+ instance Foldable RRule where
92+ foldMap f (RRule l r) = f l `mappend` f r
93+diff --git a/src/Term/Unification.hs b/src/Term/Unification.hs
94+index e1de0163..7ce6bb41 100644
95+--- a/src/Term/Unification.hs
96++++ b/src/Term/Unification.hs
97+@@ -265,9 +265,11 @@ unifyRaw l0 r0 = do
98+
99+ data MatchFailure = NoMatcher | ACProblem
100+
101++instance Semigroup MatchFailure where
102++ _ <> _ = NoMatcher
103++
104+ instance Monoid MatchFailure where
105+ mempty = NoMatcher
106+- mappend _ _ = NoMatcher
107+
108+ -- | Ensure that the computed substitution @sigma@ satisfies
109+ -- @t ==_AC apply sigma p@ after the delayed equations are solved.
pkgs/applications/science/logic/tamarin-prover/ghc-8.4-support-theory.patchnew file+130
@@ -0,0 +1,130 @@
1+From a08f6e400772899b9b0fc16befc50391cd70696b Mon Sep 17 00:00:00 2001
2+From: Felix Yan <felixonmars@archlinux.org>
3+Date: Fri, 18 May 2018 16:24:41 +0800
4+Subject: [PATCH] GHC 8.4 support
5+
6+---
7+ src/Theory/Proof.hs | 43 +++++++++++--------
8+ 11 files changed, 79 insertions(+), 48 deletions(-)
9+
10+diff --git a/src/Theory/Constraint/Solver/Reduction.hs b/src/Theory/Constraint/Solver/Reduction.hs
11+index ddbc965a..6daadd0d 100644
12+--- a/src/Theory/Constraint/Solver/Reduction.hs
13++++ b/src/Theory/Constraint/Solver/Reduction.hs
14+@@ -139,13 +139,14 @@ execReduction m ctxt se fs =
15+ data ChangeIndicator = Unchanged | Changed
16+ deriving( Eq, Ord, Show )
17+
18++instance Semigroup ChangeIndicator where
19++ Changed <> _ = Changed
20++ _ <> Changed = Changed
21++ Unchanged <> Unchanged = Unchanged
22++
23+ instance Monoid ChangeIndicator where
24+ mempty = Unchanged
25+
26+- Changed `mappend` _ = Changed
27+- _ `mappend` Changed = Changed
28+- Unchanged `mappend` Unchanged = Unchanged
29+-
30+ -- | Return 'True' iff there was a change.
31+ wasChanged :: ChangeIndicator -> Bool
32+ wasChanged Changed = True
33+diff --git a/src/Theory/Constraint/System/Guarded.hs b/src/Theory/Constraint/System/Guarded.hs
34+index f98fc7c2..2aac8ce2 100644
35+--- a/src/Theory/Constraint/System/Guarded.hs
36++++ b/src/Theory/Constraint/System/Guarded.hs
37+@@ -435,7 +435,7 @@ gall ss atos gf = GGuarded All ss atos gf
38+
39+ -- | Local newtype to avoid orphan instance.
40+ newtype ErrorDoc d = ErrorDoc { unErrorDoc :: d }
41+- deriving( Monoid, NFData, Document, HighlightDocument )
42++ deriving( Monoid, Semigroup, NFData, Document, HighlightDocument )
43+
44+ -- | @formulaToGuarded fm@ returns a guarded formula @gf@ that is
45+ -- equivalent to @fm@ under the assumption that this is possible.
46+diff --git a/src/Theory/Proof.hs b/src/Theory/Proof.hs
47+index 74fb77b1..7971b9fc 100644
48+--- a/src/Theory/Proof.hs
49++++ b/src/Theory/Proof.hs
50+@@ -388,17 +388,19 @@ data ProofStatus =
51+ | TraceFound -- ^ There is an annotated solved step
52+ deriving ( Show, Generic, NFData, Binary )
53+
54++instance Semigroup ProofStatus where
55++ TraceFound <> _ = TraceFound
56++ _ <> TraceFound = TraceFound
57++ IncompleteProof <> _ = IncompleteProof
58++ _ <> IncompleteProof = IncompleteProof
59++ _ <> CompleteProof = CompleteProof
60++ CompleteProof <> _ = CompleteProof
61++ UndeterminedProof <> UndeterminedProof = UndeterminedProof
62++
63++
64+ instance Monoid ProofStatus where
65+ mempty = CompleteProof
66+
67+- mappend TraceFound _ = TraceFound
68+- mappend _ TraceFound = TraceFound
69+- mappend IncompleteProof _ = IncompleteProof
70+- mappend _ IncompleteProof = IncompleteProof
71+- mappend _ CompleteProof = CompleteProof
72+- mappend CompleteProof _ = CompleteProof
73+- mappend UndeterminedProof UndeterminedProof = UndeterminedProof
74+-
75+ -- | The status of a 'ProofStep'.
76+ proofStepStatus :: ProofStep (Maybe a) -> ProofStatus
77+ proofStepStatus (ProofStep _ Nothing ) = UndeterminedProof
78+@@ -560,10 +562,12 @@ newtype Prover = Prover
79+ -> Maybe IncrementalProof -- resulting proof
80+ }
81+
82++instance Semigroup Prover where
83++ p1 <> p2 = Prover $ \ctxt d se ->
84++ runProver p1 ctxt d se >=> runProver p2 ctxt d se
85++
86+ instance Monoid Prover where
87+ mempty = Prover $ \_ _ _ -> Just
88+- p1 `mappend` p2 = Prover $ \ctxt d se ->
89+- runProver p1 ctxt d se >=> runProver p2 ctxt d se
90+
91+ -- | Provers whose sequencing is handled via the 'Monoid' instance.
92+ --
93+@@ -579,10 +583,12 @@ newtype DiffProver = DiffProver
94+ -> Maybe IncrementalDiffProof -- resulting proof
95+ }
96+
97++instance Semigroup DiffProver where
98++ p1 <> p2 = DiffProver $ \ctxt d se ->
99++ runDiffProver p1 ctxt d se >=> runDiffProver p2 ctxt d se
100++
101+ instance Monoid DiffProver where
102+ mempty = DiffProver $ \_ _ _ -> Just
103+- p1 `mappend` p2 = DiffProver $ \ctxt d se ->
104+- runDiffProver p1 ctxt d se >=> runDiffProver p2 ctxt d se
105+
106+ -- | Map the proof generated by the prover.
107+ mapProverProof :: (IncrementalProof -> IncrementalProof) -> Prover -> Prover
108+@@ -784,15 +790,16 @@ runAutoDiffProver (AutoProver heuristic bound cut) =
109+ -- | The result of one pass of iterative deepening.
110+ data IterDeepRes = NoSolution | MaybeNoSolution | Solution ProofPath
111+
112++instance Semigroup IterDeepRes where
113++ x@(Solution _) <> _ = x
114++ _ <> y@(Solution _) = y
115++ MaybeNoSolution <> _ = MaybeNoSolution
116++ _ <> MaybeNoSolution = MaybeNoSolution
117++ NoSolution <> NoSolution = NoSolution
118++
119+ instance Monoid IterDeepRes where
120+ mempty = NoSolution
121+
122+- x@(Solution _) `mappend` _ = x
123+- _ `mappend` y@(Solution _) = y
124+- MaybeNoSolution `mappend` _ = MaybeNoSolution
125+- _ `mappend` MaybeNoSolution = MaybeNoSolution
126+- NoSolution `mappend` NoSolution = NoSolution
127+-
128+ -- | @cutOnSolvedDFS prf@ removes all other cases if an attack is found. The
129+ -- attack search is performed using a parallel DFS traversal with iterative
130+ -- deepening.
pkgs/applications/science/logic/tamarin-prover/ghc-8.4-support-utils.patchnew file+140
@@ -0,0 +1,140 @@
1+From a08f6e400772899b9b0fc16befc50391cd70696b Mon Sep 17 00:00:00 2001
2+From: Felix Yan <felixonmars@archlinux.org>
3+Date: Fri, 18 May 2018 16:24:41 +0800
4+Subject: [PATCH] GHC 8.4 support
5+
6+---
7+ src/Extension/Data/Bounded.hs | 10 ++++-
8+ src/Extension/Data/Monoid.hs | 14 +++---
9+ src/Logic/Connectives.hs | 4 +-
10+ src/Text/PrettyPrint/Class.hs | 4 +-
11+ src/Text/PrettyPrint/Html.hs | 6 ++-
12+ 11 files changed, 79 insertions(+), 48 deletions(-)
13+
14+
15+diff --git a/src/Extension/Data/Bounded.hs b/src/Extension/Data/Bounded.hs
16+index 5f166006..f416a44c 100644
17+--- a/src/Extension/Data/Bounded.hs
18++++ b/src/Extension/Data/Bounded.hs
19+@@ -11,19 +11,25 @@ module Extension.Data.Bounded (
20+ ) where
21+
22+ -- import Data.Monoid
23++import Data.Semigroup
24+
25+ -- | A newtype wrapper for a monoid of the maximum of a bounded type.
26+ newtype BoundedMax a = BoundedMax {getBoundedMax :: a}
27+ deriving( Eq, Ord, Show )
28+
29++instance (Ord a, Bounded a) => Semigroup (BoundedMax a) where
30++ BoundedMax x <> BoundedMax y = BoundedMax (max x y)
31++
32+ instance (Ord a, Bounded a) => Monoid (BoundedMax a) where
33+ mempty = BoundedMax minBound
34+- (BoundedMax x) `mappend` (BoundedMax y) = BoundedMax (max x y)
35++ mappend = (<>)
36+
37+ -- | A newtype wrapper for a monoid of the minimum of a bounded type.
38+ newtype BoundedMin a = BoundedMin {getBoundedMin :: a}
39+ deriving( Eq, Ord, Show )
40+
41++instance (Ord a, Bounded a) => Semigroup (BoundedMin a) where
42++ BoundedMin x <> BoundedMin y = BoundedMin (min x y)
43++
44+ instance (Ord a, Bounded a) => Monoid (BoundedMin a) where
45+ mempty = BoundedMin maxBound
46+- (BoundedMin x) `mappend` (BoundedMin y) = BoundedMin (min x y)
47+\ No newline at end of file
48+diff --git a/src/Extension/Data/Monoid.hs b/src/Extension/Data/Monoid.hs
49+index 83655c34..9ce2f91b 100644
50+--- a/src/Extension/Data/Monoid.hs
51++++ b/src/Extension/Data/Monoid.hs
52+@@ -18,6 +18,7 @@ module Extension.Data.Monoid (
53+ ) where
54+
55+ import Data.Monoid
56++import Data.Semigroup
57+
58+ #if __GLASGOW_HASKELL__ < 704
59+
60+@@ -38,10 +39,13 @@ newtype MinMax a = MinMax { getMinMax :: Maybe (a, a) }
61+ minMaxSingleton :: a -> MinMax a
62+ minMaxSingleton x = MinMax (Just (x, x))
63+
64++instance Ord a => Semigroup (MinMax a) where
65++ MinMax Nothing <> y = y
66++ x <> MinMax Nothing = x
67++ MinMax (Just (xMin, xMax)) <> MinMax (Just (yMin, yMax)) =
68++ MinMax (Just (min xMin yMin, max xMax yMax))
69++
70++
71+ instance Ord a => Monoid (MinMax a) where
72+ mempty = MinMax Nothing
73+-
74+- MinMax Nothing `mappend` y = y
75+- x `mappend` MinMax Nothing = x
76+- MinMax (Just (xMin, xMax)) `mappend` MinMax (Just (yMin, yMax)) =
77+- MinMax (Just (min xMin yMin, max xMax yMax))
78++ mappend = (<>)
79+diff --git a/src/Logic/Connectives.hs b/src/Logic/Connectives.hs
80+index 2e441172..7206cc2c 100644
81+--- a/src/Logic/Connectives.hs
82++++ b/src/Logic/Connectives.hs
83+@@ -23,12 +23,12 @@ import Control.DeepSeq
84+
85+ -- | A conjunction of atoms of type a.
86+ newtype Conj a = Conj { getConj :: [a] }
87+- deriving (Monoid, Foldable, Traversable, Eq, Ord, Show, Binary,
88++ deriving (Monoid, Semigroup, Foldable, Traversable, Eq, Ord, Show, Binary,
89+ Functor, Applicative, Monad, Alternative, MonadPlus, Typeable, Data, NFData)
90+
91+ -- | A disjunction of atoms of type a.
92+ newtype Disj a = Disj { getDisj :: [a] }
93+- deriving (Monoid, Foldable, Traversable, Eq, Ord, Show, Binary,
94++ deriving (Monoid, Semigroup, Foldable, Traversable, Eq, Ord, Show, Binary,
95+ Functor, Applicative, Monad, Alternative, MonadPlus, Typeable, Data, NFData)
96+
97+ instance MonadDisj Disj where
98+diff --git a/src/Text/PrettyPrint/Class.hs b/src/Text/PrettyPrint/Class.hs
99+index f5eb42fe..13be6515 100644
100+--- a/src/Text/PrettyPrint/Class.hs
101++++ b/src/Text/PrettyPrint/Class.hs
102+@@ -187,9 +187,11 @@ instance Document Doc where
103+ nest i (Doc d) = Doc $ P.nest i d
104+ caseEmptyDoc yes no (Doc d) = if P.isEmpty d then yes else no
105+
106++instance Semigroup Doc where
107++ Doc d1 <> Doc d2 = Doc $ (P.<>) d1 d2
108++
109+ instance Monoid Doc where
110+ mempty = Doc $ P.empty
111+- mappend (Doc d1) (Doc d2) = Doc $ (P.<>) d1 d2
112+
113+ ------------------------------------------------------------------------------
114+ -- Additional combinators
115+diff --git a/src/Text/PrettyPrint/Html.hs b/src/Text/PrettyPrint/Html.hs
116+index 3de5e307..10103eb7 100644
117+--- a/src/Text/PrettyPrint/Html.hs
118++++ b/src/Text/PrettyPrint/Html.hs
119+@@ -90,7 +90,7 @@ attribute (key,value) = " " ++ key ++ "=\"" ++ escapeHtmlEntities value ++ "\""
120+
121+ -- | A 'Document' transformer that adds proper HTML escaping.
122+ newtype HtmlDoc d = HtmlDoc { getHtmlDoc :: d }
123+- deriving( Monoid )
124++ deriving( Monoid, Semigroup )
125+
126+ -- | Wrap a document such that HTML markup can be added without disturbing the
127+ -- layout.
128+@@ -182,9 +182,11 @@ getNoHtmlDoc = runIdentity . unNoHtmlDoc
129+ instance NFData d => NFData (NoHtmlDoc d) where
130+ rnf = rnf . getNoHtmlDoc
131+
132++instance Semigroup d => Semigroup (NoHtmlDoc d) where
133++ (<>) = liftA2 (<>)
134++
135+ instance Monoid d => Monoid (NoHtmlDoc d) where
136+ mempty = pure mempty
137+- mappend = liftA2 mappend
138+
139+ instance Document d => Document (NoHtmlDoc d) where
140+ char = pure . char