on master help sign in
Don't match against class ops in compareLength rules

The LHS needs to match against the monomorphic equivalents (in this case `eqInt`, `ltInt`, and friends) for these rules to reliably fire. Otherwise the `Eq` or `Ord` class op rewrites may be applied before the `compareLength` has a chance to be applied.

commit0fd610a19982253e4ecd4644028f020db3d1bc0b authorBen Gamari <ben@smart-cactus.org> dateWed 30 Mar 2016, 10:14 (11 years ago) parent0cf7d06
1 file changed+7−6
Data/Text.hs+7−6
Data/Text.hs+7−6
@@ -238,6 +238,7 @@ import Data.ByteString (ByteString)
238238import qualified Data.Text.Lazy as L
239239import Data.Int (Int64)
240240#endif
241+import GHC.Base (eqInt, neInt, gtInt, geInt, ltInt, leInt)
241242#if __GLASGOW_HASKELL__ >= 708
242243import qualified GHC.Exts as Exts
243244#endif
@@ -592,32 +593,32 @@ compareLength t n = S.compareLengthI (stream t) n
592593
593594{-# RULES
594595"TEXT ==N/length -> compareLength/==EQ" [~1] forall t n.
595− (==) (length t) n = compareLength t n == EQ
596+ eqInt (length t) n = compareLength t n == EQ
596597 #-}
597598
598599{-# RULES
599600"TEXT /=N/length -> compareLength//=EQ" [~1] forall t n.
600− (/=) (length t) n = compareLength t n /= EQ
601+ neInt (length t) n = compareLength t n /= EQ
601602 #-}
602603
603604{-# RULES
604605"TEXT <N/length -> compareLength/==LT" [~1] forall t n.
605− (<) (length t) n = compareLength t n == LT
606+ ltInt (length t) n = compareLength t n == LT
606607 #-}
607608
608609{-# RULES
609610"TEXT <=N/length -> compareLength//=GT" [~1] forall t n.
610− (<=) (length t) n = compareLength t n /= GT
611+ leInt (length t) n = compareLength t n /= GT
611612 #-}
612613
613614{-# RULES
614615"TEXT >N/length -> compareLength/==GT" [~1] forall t n.
615− (>) (length t) n = compareLength t n == GT
616+ gtInt (length t) n = compareLength t n == GT
616617 #-}
617618
618619{-# RULES
619620"TEXT >=N/length -> compareLength//=LT" [~1] forall t n.
620− (>=) (length t) n = compareLength t n /= LT
621+ geInt (length t) n = compareLength t n /= LT
621622 #-}
622623
623624-- -----------------------------------------------------------------------------