From 4bccb87e864615c08f449430e3c1a48b7a50944e Mon Sep 17 00:00:00 2001 From: Kai-Oliver Prott Date: Mon, 15 Apr 2019 15:47:10 +0200 Subject: [PATCH] Fix bug when deriving instances of Bounded type class --- CHANGELOG.md | 1 + src/Checks/InstanceCheck.hs | 2 +- src/Transformations/Derive.hs | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69ead6d3..3013945e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Version 1.0.4 ============= * Fixed bug in type checking of instances + * Fixed bugs in deriving of `Bounded` instances. Version 1.0.3 ============= diff --git a/src/Checks/InstanceCheck.hs b/src/Checks/InstanceCheck.hs index 957411ec..bad59d26 100644 --- a/src/Checks/InstanceCheck.hs +++ b/src/Checks/InstanceCheck.hs @@ -196,7 +196,7 @@ bindDerivedInstance clsEnv p tc pty tys cls = do , (fromEnumId, 1), (enumFromId, 1) , (enumFromThenId, 2) ] - | cls == qBoundedId = [(maxBoundId, 1), (minBoundId, 1)] + | cls == qBoundedId = [(maxBoundId, 0), (minBoundId, 0)] | cls == qReadId = [(readsPrecId, 2)] | cls == qShowId = [(showsPrecId, 2)] | otherwise = diff --git a/src/Transformations/Derive.hs b/src/Transformations/Derive.hs index 8b73c40c..b6f0d834 100644 --- a/src/Transformations/Derive.hs +++ b/src/Transformations/Derive.hs @@ -274,8 +274,8 @@ enumFromThenExpr v1 v2 c1 c2 = deriveBoundedMethods :: Type -> [ConstrInfo] -> PredSet -> DVM [Decl PredType] deriveBoundedMethods ty cis ps = sequence - [ deriveMaxOrMinBound qMaxBoundId ty (head cis) ps - , deriveMaxOrMinBound qMinBoundId ty (last cis) ps + [ deriveMaxOrMinBound qMinBoundId ty (head cis) ps + , deriveMaxOrMinBound qMaxBoundId ty (last cis) ps ] deriveMaxOrMinBound :: QualIdent -> Type -> ConstrInfo -> PredSet -- GitLab