~ubuntu-branches/ubuntu/precise/haskell-text/precise

« back to all changes in this revision

Viewing changes to Data/Text/Util.hs

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-04-13 11:38:29 UTC
  • mfrom: (4.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110413113829-f4ss61ivg720e5bu
Tags: 0.11.0.6-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{-# LANGUAGE CPP, DeriveDataTypeable #-}
 
2
 
 
3
-- |
 
4
-- Module      : Data.Text.Util
 
5
-- Copyright   : 2010 Bryan O'Sullivan
 
6
--
 
7
-- License     : BSD-style
 
8
-- Maintainer  : bos@serpentine.com
 
9
-- Stability   : experimental
 
10
-- Portability : GHC
 
11
--
 
12
-- Useful functions.
 
13
 
 
14
module Data.Text.Util
 
15
    (
 
16
      intersperse
 
17
    ) where
 
18
 
 
19
-- | A lazier version of Data.List.intersperse.  The other version
 
20
-- causes space leaks!
 
21
intersperse :: a -> [a] -> [a]
 
22
intersperse _   []     = []
 
23
intersperse sep (x:xs) = x : go xs
 
24
  where
 
25
    go []     = []
 
26
    go (y:ys) = sep : y: go ys
 
27
{-# INLINE intersperse #-}