summaryrefslogtreecommitdiffstats
path: root/src/Data/ByteString
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2019-01-27 18:52:25 +0100
committertv <tv@krebsco.de>2019-01-27 18:52:25 +0100
commit4d85ce5584c5bc69b402b7d3b94c623f37ea69f5 (patch)
treeeb1b5b01b521b7d8c695384f3e731413a0f5689a /src/Data/ByteString
parent32ddebc0309a73c50e0f1974b4f9435fce3f86c9 (diff)
src: replace all undefined with typeMismatch
Diffstat (limited to 'src/Data/ByteString')
-rw-r--r--src/Data/ByteString/Char8/Extended.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Data/ByteString/Char8/Extended.hs b/src/Data/ByteString/Char8/Extended.hs
index ca0c44a..8bf76c7 100644
--- a/src/Data/ByteString/Char8/Extended.hs
+++ b/src/Data/ByteString/Char8/Extended.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.ByteString.Char8.Extended
( module Data.ByteString.Char8
@@ -5,14 +6,16 @@ module Data.ByteString.Char8.Extended
) where
import Data.Aeson
+import Data.Aeson.Types (typeMismatch)
import Data.ByteString.Char8
import Data.Text.Encoding (encodeUtf8)
import Prelude hiding (show)
import qualified Prelude
instance FromJSON ByteString where
- parseJSON (String t) = pure (encodeUtf8 t)
- parseJSON _ = pure undefined
+ parseJSON = \case
+ String t -> pure (encodeUtf8 t)
+ invalid -> typeMismatch "ByteString" invalid
instance FromJSONKey ByteString where
fromJSONKey = FromJSONKeyText encodeUtf8