diff options
author | tv <tv@krebsco.de> | 2019-01-21 19:14:55 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2019-01-21 19:19:05 +0100 |
commit | 2842e05c232505c670daee0fffb9a34d5c866217 (patch) | |
tree | 90ffcdea7130b5811b6e02f931c5b1cc27a3191f /src | |
parent | ce276eee82ec0b8c4106beb4c51d6f9eb77335c4 (diff) |
src: add Data.ByteString.Char8.Extended
Diffstat (limited to 'src')
-rw-r--r-- | src/Data/ByteString/Char8/Extended.hs | 15 | ||||
-rw-r--r-- | src/Reaktor.hs | 2 | ||||
-rw-r--r-- | src/Reaktor/Message.hs | 2 | ||||
-rw-r--r-- | src/Reaktor/Parser.hs | 2 | ||||
-rw-r--r-- | src/Reaktor/Plugins/Mention.hs | 2 | ||||
-rw-r--r-- | src/Reaktor/Plugins/NickServ.hs | 2 | ||||
-rw-r--r-- | src/Reaktor/Plugins/Register.hs | 2 | ||||
-rw-r--r-- | src/Reaktor/Plugins/System.hs | 2 | ||||
-rw-r--r-- | src/Reaktor/Plugins/System/Types.hs | 2 | ||||
-rw-r--r-- | src/Reaktor/Types.hs | 12 | ||||
-rw-r--r-- | src/Reaktor/Utils.hs | 2 |
11 files changed, 25 insertions, 20 deletions
diff --git a/src/Data/ByteString/Char8/Extended.hs b/src/Data/ByteString/Char8/Extended.hs new file mode 100644 index 0000000..4d46cd2 --- /dev/null +++ b/src/Data/ByteString/Char8/Extended.hs @@ -0,0 +1,15 @@ +{-# OPTIONS_GHC -fno-warn-orphans #-} +module Data.ByteString.Char8.Extended + ( module Data.ByteString.Char8 + ) where + +import Data.Aeson +import Data.ByteString.Char8 +import Data.Text.Encoding (encodeUtf8) + +instance FromJSON ByteString where + parseJSON (String t) = pure (encodeUtf8 t) + parseJSON _ = pure undefined + +instance FromJSONKey ByteString where + fromJSONKey = FromJSONKeyText encodeUtf8 diff --git a/src/Reaktor.hs b/src/Reaktor.hs index 110485f..5f1e709 100644 --- a/src/Reaktor.hs +++ b/src/Reaktor.hs @@ -12,7 +12,7 @@ import Control.Monad.Trans.State.Lazy import Data.Aeson import Data.Attoparsec.ByteString.Char8 (IResult(Done,Fail,Partial)) import Data.Attoparsec.ByteString.Char8 (feed,parse) -import qualified Data.ByteString.Char8 as BS +import qualified Data.ByteString.Char8.Extended as BS import Data.Foldable (toList) import qualified Data.Text as T import Data.Time.Clock.System diff --git a/src/Reaktor/Message.hs b/src/Reaktor/Message.hs index f929471..c1c7ced 100644 --- a/src/Reaktor/Message.hs +++ b/src/Reaktor/Message.hs @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} module Reaktor.Message where -import qualified Data.ByteString.Char8 as BS +import qualified Data.ByteString.Char8.Extended as BS import Reaktor.Types diff --git a/src/Reaktor/Parser.hs b/src/Reaktor/Parser.hs index bdd2f98..3baaad7 100644 --- a/src/Reaktor/Parser.hs +++ b/src/Reaktor/Parser.hs @@ -3,7 +3,7 @@ module Reaktor.Parser where import Control.Applicative import Data.Attoparsec.ByteString.Char8 -import qualified Data.ByteString.Char8 as BS +import qualified Data.ByteString.Char8.Extended as BS import qualified Data.Char import Reaktor.Types diff --git a/src/Reaktor/Plugins/Mention.hs b/src/Reaktor/Plugins/Mention.hs index 0c86d74..a08604c 100644 --- a/src/Reaktor/Plugins/Mention.hs +++ b/src/Reaktor/Plugins/Mention.hs @@ -4,7 +4,7 @@ module Reaktor.Plugins.Mention (plugin) where import Control.Monad (when) import Data.Aeson -import qualified Data.ByteString.Char8 as BS +import qualified Data.ByteString.Char8.Extended as BS import qualified Data.Char import Reaktor.Message import Reaktor.Types diff --git a/src/Reaktor/Plugins/NickServ.hs b/src/Reaktor/Plugins/NickServ.hs index 3987774..caa2301 100644 --- a/src/Reaktor/Plugins/NickServ.hs +++ b/src/Reaktor/Plugins/NickServ.hs @@ -7,7 +7,7 @@ module Reaktor.Plugins.NickServ (plugin) where import Control.Monad (when) import Data.Aeson import Data.Aeson.Types (parseEither) -import qualified Data.ByteString.Char8 as BS +import qualified Data.ByteString.Char8.Extended as BS import GHC.Generics import Reaktor.Message import Reaktor.Types diff --git a/src/Reaktor/Plugins/Register.hs b/src/Reaktor/Plugins/Register.hs index fd17f48..48c3ff2 100644 --- a/src/Reaktor/Plugins/Register.hs +++ b/src/Reaktor/Plugins/Register.hs @@ -6,7 +6,7 @@ module Reaktor.Plugins.Register (plugin) where import Control.Monad (when) import Data.Aeson -import qualified Data.ByteString.Char8 as BS +import qualified Data.ByteString.Char8.Extended as BS import GHC.Generics import Reaktor.Types import Reaktor.Utils (nextNick,randomNick) diff --git a/src/Reaktor/Plugins/System.hs b/src/Reaktor/Plugins/System.hs index c8d40be..4e659d1 100644 --- a/src/Reaktor/Plugins/System.hs +++ b/src/Reaktor/Plugins/System.hs @@ -9,7 +9,7 @@ import Control.Applicative import Control.Concurrent (forkIO) import Control.Exception (finally) import Data.Aeson -import qualified Data.ByteString.Char8 as BS +import qualified Data.ByteString.Char8.Extended as BS import qualified Data.Map as M import Reaktor.Message import Reaktor.Plugins.System.Types diff --git a/src/Reaktor/Plugins/System/Types.hs b/src/Reaktor/Plugins/System/Types.hs index 48ec51a..39d2f75 100644 --- a/src/Reaktor/Plugins/System/Types.hs +++ b/src/Reaktor/Plugins/System/Types.hs @@ -2,7 +2,7 @@ module Reaktor.Plugins.System.Types where import Data.Aeson -import qualified Data.ByteString.Char8 as BS +import qualified Data.ByteString.Char8.Extended as BS import qualified Data.Map as M import Reaktor.Types () diff --git a/src/Reaktor/Types.hs b/src/Reaktor/Types.hs index f2115be..7b5e8fa 100644 --- a/src/Reaktor/Types.hs +++ b/src/Reaktor/Types.hs @@ -1,5 +1,4 @@ {-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} module Reaktor.Types (module Reaktor.Types, module X) where import Blessings (Blessings) @@ -8,8 +7,7 @@ import Control.Monad.Trans.State as X (gets,modify) import Control.Monad.Trans.State (StateT) import Data.Aeson import Data.Aeson.Types -import qualified Data.ByteString.Char8 as BS -import qualified Data.Text.Encoding as T +import qualified Data.ByteString.Char8.Extended as BS import Network.Socket as X (HostName,ServiceName) @@ -58,11 +56,3 @@ type Param = BS.ByteString type Command = BS.ByteString data Message = Message (Maybe Prefix) Command [Param] deriving Show - - -instance FromJSON BS.ByteString where - parseJSON (String t) = pure (T.encodeUtf8 t) - parseJSON _ = pure undefined - -instance FromJSONKey BS.ByteString where - fromJSONKey = FromJSONKeyText T.encodeUtf8 diff --git a/src/Reaktor/Utils.hs b/src/Reaktor/Utils.hs index bc08a81..725775e 100644 --- a/src/Reaktor/Utils.hs +++ b/src/Reaktor/Utils.hs @@ -1,6 +1,6 @@ module Reaktor.Utils where -import qualified Data.ByteString.Char8 as BS +import qualified Data.ByteString.Char8.Extended as BS import Data.Char (chr) import Data.Char (isDigit) import Reaktor.Types |