dstring 0.1 → 0.2
raw patch · 2 files changed
+35/−3 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/DString.hs +29/−1
- dstring.cabal +6/−2
Data/DString.hs view
@@ -6,7 +6,7 @@ -- -- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com> -- Stability : experimental--- Portability : portable (Haskell 98)+-- Portability : Only requires OverloadedStrings -- -- Difference strings: a data structure for O(1) append on -- strings. Note that a DString is just a newtype wrapper around a@@ -46,6 +46,31 @@ import Data.Monoid import Data.String ++-- | A difference string is a function that given a string, returns+-- the original contents of the difference string prepended at the+-- given string.+--+-- This structure supports O(1) @append@ en @snoc@ operations on+-- strings making it very usefull for append-heavy uses such as+-- logging and pretty printing.+--+-- You can use it to efficiently show a tree for example:+-- (Note that we make use of some functions from the /string-combinators/ package:+-- <http://hackage.haskell.org/cgi-bin/hackage-scripts/package/string-combinators>)+--+-- > {-# LANGUAGE OverloadedStrings #-}+-- >+-- > import Data.DString+-- > import Data.String.Combinators ((<+>), fromShow, paren)+-- >+-- > data Tree a = Leaf a | Branch (Tree a) (Tree a)+-- >+-- > instance Show a => Show (Tree a) where+-- > show = toString . go+-- > where+-- > go (Leaf x) = "Leaf" <+> fromShow x+-- > go (Branch l r) = "Branch" <+> paren (go l) <+> paren (go r) newtype DString = DS { toDList :: D.DList Char -- ^ Convert a difference string to a difference list } @@ -60,6 +85,8 @@ instance IsString DString where fromString = fromDList . D.fromList +-- Conversions+ -- | Convert a difference string back to a normal String toString :: DString -> String toString = D.toList . toDList@@ -118,3 +145,4 @@ -- | Foldr over difference strings foldr :: (Char -> b -> b) -> b -> DString -> b foldr f b = D.foldr f b . toDList+
dstring.cabal view
@@ -1,5 +1,5 @@ Name: dstring-Version: 0.1+Version: 0.2 Synopsis: Difference strings. Description: Difference strings: a data structure for O(1) append on@@ -14,9 +14,13 @@ Author: Bas van Dijk <v.dijk.bas@gmail.com> Maintainer: Bas van Dijk <v.dijk.bas@gmail.com> Copyright: 2009 Bas van Dijk <v.dijk.bas@gmail.com>-Cabal-version: >= 1.2+Cabal-version: >= 1.6 Build-Type: Simple Stability: experimental++Source-repository head+ Type: darcs+ Location: http://code.haskell.org/~basvandijk/code/dstring Library Build-Depends: base, dlist