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 :: [Char] -> Maybe (Char, [Char])
uncons [] = forall a. Maybe a
Nothing
uncons (Char
x:[Char]
xs) = forall a. a -> Maybe a
Just (Char
x,[Char]
xs)
instance Uncons (Seq Char) where
uncons :: Seq Char -> Maybe (Char, Seq Char)
uncons Seq Char
s = case forall a. Seq a -> ViewL a
viewl Seq Char
s of
ViewL Char
EmptyL -> forall a. Maybe a
Nothing
Char
x :< Seq Char
xs -> forall a. a -> Maybe a
Just (Char
x,Seq Char
xs)
instance Uncons SBS.ByteString where
uncons :: ByteString -> Maybe (Char, ByteString)
uncons = ByteString -> Maybe (Char, ByteString)
SBS.uncons
instance Uncons LBS.ByteString where
uncons :: ByteString -> Maybe (Char, ByteString)
uncons = ByteString -> Maybe (Char, ByteString)
LBS.uncons
instance Uncons T.Text where
uncons :: Text -> Maybe (Char, Text)
uncons = Text -> Maybe (Char, Text)
T.uncons
instance Uncons TL.Text where
uncons :: Text -> Maybe (Char, Text)
uncons = Text -> Maybe (Char, Text)
TL.uncons