{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
module Errata.Source
( Source (..)
) where
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
class Source s where
emptySource :: s
sourceToLines :: s -> [s]
sourceToText :: s -> T.Text
instance Source String where
emptySource :: String
emptySource = String
""
sourceToLines :: String -> [String]
sourceToLines = String -> [String]
lines
sourceToText :: String -> Text
sourceToText = String -> Text
T.pack
instance Source T.Text where
emptySource :: Text
emptySource = Text
""
sourceToLines :: Text -> [Text]
sourceToLines = Text -> [Text]
T.lines
sourceToText :: Text -> Text
sourceToText = Text -> Text
forall a. a -> a
id
instance Source TL.Text where
emptySource :: Text
emptySource = Text
""
sourceToLines :: Text -> [Text]
sourceToLines = Text -> [Text]
TL.lines
sourceToText :: Text -> Text
sourceToText = Text -> Text
TL.toStrict