Commits

Bryan O'Sullivan  committed ba10b67

Implement cons

  • Participants
  • Parent commits f8c1e64

Comments (0)

Files changed (1)

File Data/Text/Lazy.hs

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