T.P.Shared: Remove ToString, ToText typeclasses [API change].

T.P.Parsing: revise type of readWithM so that it takes a Text
rather than a polymorphic ToText value.

These typeclasses were there to ease the transition from String
to Text. They are no longer needed, and they may clash with
more useful versions under the same name.

This will require a bump to 2.13.
This commit is contained in:
John MacFarlane 2021-03-19 12:34:20 -07:00
parent 425c2e47b5
commit 005f0fbcd5
2 changed files with 4 additions and 24 deletions

View file

@ -1128,13 +1128,13 @@ gridTableFooter = optional blanklines
---
-- | Removes the ParsecT layer from the monad transformer stack
readWithM :: (Stream s m Char, ToText s)
=> ParserT s st m a -- ^ parser
readWithM :: Monad m
=> ParserT Text st m a -- ^ parser
-> st -- ^ initial state
-> s -- ^ input
-> Text -- ^ input
-> m (Either PandocError a)
readWithM parser state input =
mapLeft (PandocParsecError $ toText input) `liftM` runParserT parser state "source" input
mapLeft (PandocParsecError input) <$> runParserT parser state "source" input
-- | Parse a string with a given parser and state
readWith :: Parser Text st a

View file

@ -25,8 +25,6 @@ module Text.Pandoc.Shared (
ordNub,
findM,
-- * Text processing
ToString (..),
ToText (..),
tshow,
backslashEscapes,
escapeStringUsing,
@ -183,24 +181,6 @@ findM p = foldr go (pure Nothing)
-- Text processing
--
class ToString a where
toString :: a -> String
instance ToString String where
toString = id
instance ToString T.Text where
toString = T.unpack
class ToText a where
toText :: a -> T.Text
instance ToText String where
toText = T.pack
instance ToText T.Text where
toText = id
tshow :: Show a => a -> T.Text
tshow = T.pack . show