[commit: packages/containers] changelog-foldtree, cleaned_bugfix394, master, merge-doc-target, merge-fixes-5.9, merge-restrict-fix-5.8, revert-184-generic, revert-408-bugfix_394: Make reverse helpers polymorphic (32478c0)

git at git.haskell.org git at git.haskell.org
Mon Apr 17 21:38:58 UTC 2017


Repository : ssh://git@git.haskell.org/containers

On branches: changelog-foldtree,cleaned_bugfix394,master,merge-doc-target,merge-fixes-5.9,merge-restrict-fix-5.8,revert-184-generic,revert-408-bugfix_394
Link       : http://git.haskell.org/packages/containers.git/commitdiff/32478c093ae17ba5f9295012eb1580764d15ad8a

>---------------------------------------------------------------

commit 32478c093ae17ba5f9295012eb1580764d15ad8a
Author: David Feuer <David.Feuer at gmail.com>
Date:   Tue Jan 19 02:14:53 2016 -0500

    Make reverse helpers polymorphic
    
    Lean a bit harder on the type system to ensure that the
    reversing function is called everywhere it's supposed
    to be. Yes, this should all be covered by the test suite
    anyway, but it can't hurt.


>---------------------------------------------------------------

32478c093ae17ba5f9295012eb1580764d15ad8a
 Data/Sequence.hs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Data/Sequence.hs b/Data/Sequence.hs
index c3a1e1d..2915d90 100644
--- a/Data/Sequence.hs
+++ b/Data/Sequence.hs
@@ -2131,7 +2131,7 @@ instance IsString (Seq Char) where
 reverse :: Seq a -> Seq a
 reverse (Seq xs) = Seq (reverseTree id xs)
 
-reverseTree :: (a -> a) -> FingerTree a -> FingerTree a
+reverseTree :: (a -> b) -> FingerTree a -> FingerTree b
 reverseTree _ Empty = Empty
 reverseTree f (Single x) = Single (f x)
 reverseTree f (Deep s pr m sf) =
@@ -2140,13 +2140,13 @@ reverseTree f (Deep s pr m sf) =
         (reverseDigit f pr)
 
 {-# INLINE reverseDigit #-}
-reverseDigit :: (a -> a) -> Digit a -> Digit a
+reverseDigit :: (a -> b) -> Digit a -> Digit b
 reverseDigit f (One a) = One (f a)
 reverseDigit f (Two a b) = Two (f b) (f a)
 reverseDigit f (Three a b c) = Three (f c) (f b) (f a)
 reverseDigit f (Four a b c d) = Four (f d) (f c) (f b) (f a)
 
-reverseNode :: (a -> a) -> Node a -> Node a
+reverseNode :: (a -> b) -> Node a -> Node b
 reverseNode f (Node2 s a b) = Node2 s (f b) (f a)
 reverseNode f (Node3 s a b c) = Node3 s (f c) (f b) (f a)
 



More information about the ghc-commits mailing list