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
-> forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
""
| Bool
otherwise -> Tag
FromListNTag forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ReadP Char
get
String
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return Tag
FromListTag