~ubuntu-branches/ubuntu/trusty/haskell-text/trusty

« back to all changes in this revision

Viewing changes to Data/Text/Fusion/Common.hs

  • Committer: Package Import Robot
  • Author(s): Joachim Breitner
  • Date: 2013-05-27 15:29:56 UTC
  • mfrom: (4.2.2 sid)
  • Revision ID: package-import@ubuntu.com-20130527152956-2mj3ud1ahuv386b1
Tags: 0.11.3.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
 
173
173
-- | /O(n)/ Adds a character to the front of a Stream Char.
174
174
cons :: Char -> Stream Char -> Stream Char
175
 
cons w (Stream next0 s0 len) = Stream next (C1 s0) (len+1)
 
175
cons !w (Stream next0 s0 len) = Stream next (C1 s0) (len+1)
176
176
    where
177
177
      next (C1 s) = Yield w (C0 s)
178
178
      next (C0 s) = case next0 s of
218
218
      loop_head !s = case next s of
219
219
                      Yield x _ -> x
220
220
                      Skip s'   -> loop_head s'
221
 
                      Done      -> streamError "head" "Empty stream"
 
221
                      Done      -> head_empty
222
222
{-# INLINE [0] head #-}
223
223
 
 
224
head_empty :: a
 
225
head_empty = streamError "head" "Empty stream"
 
226
{-# NOINLINE head_empty #-}
 
227
 
224
228
-- | /O(1)/ Returns the first character and remainder of a 'Stream
225
229
-- Char', or 'Nothing' if empty.  Subject to array fusion.
226
230
uncons :: Stream Char -> Maybe (Char, Stream Char)