on master help sign in
Implement cons

--HG-- extra : convert_revision : ba0b3b09c9dd20b1e608d8690c850b6c3910b334

commit9dd93d840be41ad77371d62898e75fd0b1a3d5c7 authorBryan O'Sullivan <bos@serpentine.com> dateSun 1 Mar 2009, 06:13 (18 years ago) parent42244c9
1 file changed+12−1
Data/Text/Lazy.hs+12−1
Data/Text/Lazy.hs+12−1
@@ -40,7 +40,7 @@ module Data.Text.Lazy
4040 , empty
4141
4242 -- * Basic interface
43− -- , cons
43+ , cons
4444 -- , snoc
4545 , append
4646 -- , uncons
@@ -194,6 +194,17 @@ singleton c = Chunk (T.singleton c) Empty
194194 unstream (S.singleton c) = singleton c
195195 #-}
196196
197+cons :: Char -> Text -> Text
198+cons c t = Chunk (T.singleton c) t
199+{-# INLINE [1] cons #-}
200+
201+{-# RULES
202+"LAZY TEXT cons -> fused" [~1] forall c t.
203+ cons c t = unstream (S.cons c (stream t))
204+"LAZY TEXT cons -> unfused" [1] forall c t.
205+ unstream (S.cons c (stream t)) = cons c t
206+ #-}
207+
197208-- | /O(n\/c)/ Append two 'Text's
198209append :: Text -> Text -> Text
199210append xs ys = foldrChunks Chunk ys xs