Commits

Bryan O'Sullivan committed 4f7fc04

Implement lazy snoc

  • Participants
  • Parent commits b213e79

Comments (0)

Files changed (1)

File Data/Text/Lazy.hs

 
     -- * Basic interface
     , cons
-    -- , snoc
+    , snoc
     , append
     -- , uncons
     -- , head
     unstream (S.cons c (stream t)) = cons c t
  #-}
 
+snoc :: Text -> Char -> Text
+snoc t c = foldrChunks Chunk (singleton c) t
+{-# INLINE [1] snoc #-}
+
+{-# RULES
+"LAZY TEXT snoc -> fused" [~1] forall t c.
+    snoc t c = unstream (S.snoc (stream t) c)
+"LAZY TEXT snoc -> unfused" [1] forall t c.
+    unstream (S.snoc (stream t) c) = snoc t c
+ #-}
+
 -- | /O(n\/c)/ Append two 'Text's
 append :: Text -> Text -> Text
 append xs ys = foldrChunks Chunk ys xs