module Text.Regex.TDFA.NewDFA.Uncons(Uncons(uncons)) where
import qualified Data.ByteString.Char8 as SBS(ByteString,uncons)
import qualified Data.ByteString.Lazy.Char8 as LBS(ByteString,uncons)
import Data.Sequence(Seq,viewl,ViewL(EmptyL,(:<)))
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
class Uncons a where
uncons :: a -> Maybe (Char,a)
instance Uncons ([] Char) where
uncons [] = Nothing
uncons (x:xs) = Just (x,xs)
instance Uncons (Seq Char) where
uncons s = case viewl s of
EmptyL -> Nothing
x :< xs -> Just (x,xs)
instance Uncons SBS.ByteString where
uncons = SBS.uncons
instance Uncons LBS.ByteString where
uncons = LBS.uncons
instance Uncons T.Text where
uncons = T.uncons
instance Uncons TL.Text where
uncons = TL.uncons