{-# LANGUAGE OverloadedStrings #-}
module Data.Sv.Structure.Newline (
Newline (UnsafeMkNewline, toByteString)
, newlineToBuilder
, crlf
, lf
) where
import Data.ByteString (ByteString)
import Data.ByteString.Builder (Builder, byteString)
import qualified Data.ByteString.UTF8 as UTF8
newtype Newline
= UnsafeMkNewline { toByteString :: ByteString }
deriving (Eq, Ord)
instance Show Newline where
showsPrec _ = showString . UTF8.toString . toByteString
newlineToBuilder :: Newline -> Builder
newlineToBuilder = byteString . toByteString
lf :: Newline
lf = UnsafeMkNewline "\n"
crlf :: Newline
crlf = UnsafeMkNewline "\r\n"