{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
module Network.Damn.Format.IRC
( ircFormat
, Lines
, unLines
) where
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import Data.Semigroup.Compat
import Data.String
import Data.Text.Encoding
import Network.Damn.Format.Base
import Network.Damn.Format.Damn.Internal
import Prelude.Compat
newtype Lines =
Lines ByteString
deriving (Show, Monoid, Semigroup, IsString)
unLines :: Lines -> [ByteString]
unLines (Lines bs) = B.split 10 bs
ircFormat :: Formatter Lines
ircFormat = either (Lines . encodeUtf8) (Lines . ircFormat')
ircFormat' :: Lump -> ByteString
ircFormat' B = "\x02"
ircFormat' C_B = "\x02"
ircFormat' Br = "\n"
ircFormat' I = "\x1D"
ircFormat' C_I = "\x1D"
ircFormat' U = "\x1F"
ircFormat' C_U = "\x1F"
ircFormat' x = damnFormat' x