diff options
author | tv <tv@krebsco.de> | 2019-01-27 18:52:25 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2019-01-27 18:52:25 +0100 |
commit | 4d85ce5584c5bc69b402b7d3b94c623f37ea69f5 (patch) | |
tree | eb1b5b01b521b7d8c695384f3e731413a0f5689a /src/Data/ByteString | |
parent | 32ddebc0309a73c50e0f1974b4f9435fce3f86c9 (diff) |
src: replace all undefined with typeMismatch
Diffstat (limited to 'src/Data/ByteString')
-rw-r--r-- | src/Data/ByteString/Char8/Extended.hs | 7 |
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 |