Permalink
Browse files

Add 'null' function

darcs-hash:20080310162151-5035a-172e142e2e0056ff6c0ed438aa2fa25a9b6437c9.gz
  • Loading branch information...
1 parent 1fdd5ea commit fcbc786b0caa959bccccd99954b4fbebf83b73da @yav yav committed Mar 10, 2008
Showing with 7 additions and 1 deletion.
  1. +7 −1 Data/String/UTF8.hs
View
8 Data/String/UTF8.hs
@@ -24,13 +24,15 @@ module Data.String.UTF8
, lines'
-- * Representation based operations
+ , null
, decode
, byteSplitAt
, byteTake
, byteDrop
) where
-import Prelude hiding (take,drop,span,break,foldl,foldr,length,lines,splitAt)
+import Prelude hiding (null,take,drop,span,break
+ ,foldl,foldr,length,lines,splitAt)
import qualified Codec.Binary.UTF8.Generic as G
import Codec.Binary.UTF8.Generic (UTF8Bytes)
@@ -58,6 +60,10 @@ fromString xs = Str (G.fromString xs)
toString :: UTF8Bytes string index => UTF8 string -> String
toString (Str xs) = G.toString xs
+-- | Checks if there are no more bytes in the underlying representation.
+null :: UTF8Bytes string index => UTF8 string -> Bool
+null (Str x) = G.null x
+
-- | Split after a given number of characters.
-- Negative values are treated as if they are 0.
-- See also 'bytesSplitAt'.

0 comments on commit fcbc786

Please sign in to comment.