module Data.Primitive.Internal.Read
( Tag(..)
, lexTag
) where
import Data.Char (isDigit)
import Text.ParserCombinators.ReadP
data Tag = FromListTag | FromListNTag
lexTag :: ReadP Tag
lexTag :: ReadP Tag
lexTag = do
String
_ <- String -> ReadP String
string String
"fromList"
String
s <- ReadP String
look
case String
s of
Char
'N':Char
c:String
_
| Char -> Bool
isDigit Char
c
-> String -> ReadP Tag
forall a. String -> ReadP a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
""
| Bool
otherwise -> Tag
FromListNTag Tag -> ReadP Char -> ReadP Tag
forall a b. a -> ReadP b -> ReadP a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ReadP Char
get
String
_ -> Tag -> ReadP Tag
forall a. a -> ReadP a
forall (m :: * -> *) a. Monad m => a -> m a
return Tag
FromListTag