Commits

Bryan O'Sullivan  committed 722cb5a

Re-add fusion to definition of uncons

  • Participants
  • Parent commits aa61898

Comments (0)

Files changed (1)

File Data/Text.hs

           n             = A.unsafeIndex arr (off+1)
 {-# INLINE uncons #-}
 
--- | /O(n)/ Returns the last character of a 'Text', which must be
+second :: (b -> c) -> (a,b) -> (a,c)
+second f (a, b) = (a, f b)
+
+{-# RULES
+"TEXT uncons -> fused" [~1] forall t.
+    uncons t = fmap (second unstream) (S.uncons (stream t))
+"TEXT uncons -> unfused" [1] forall t.
+    fmap (second unstream) (S.uncons (stream t)) = uncons t
+  #-}
+
+-- | /O(1)/ Returns the last character of a 'Text', which must be
 -- non-empty.  Subject to array fusion.
 last :: Text -> Char
 last (Text arr off len)