packages feed

rest-types 1.13 → 1.13.1

raw patch · 4 files changed

+39/−1 lines, 4 files

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog +### 1.13.1++* Add `Applicative` and `Monad` instances for `Reason`.+* Add `Eq`, `Ord` and `Read` instances for `Void`.+ ## 1.13  * Change the type of `Reason_` from `Reason ()` to `Reason Void`
rest-types.cabal view
@@ -1,5 +1,5 @@ name:                rest-types-version:             1.13+version:             1.13.1 description:         Silk Rest Framework Types synopsis:            Silk Rest Framework Types maintainer:          code@silk.co
src/Rest/Types/Error.hs view
@@ -23,6 +23,8 @@   , ToResponseCode (..)   ) where +import Control.Applicative (Applicative (..))+import Control.Monad (ap) import Data.Aeson hiding (Success) import Data.Foldable (Foldable) import Data.JSON.Schema (JSONSchema (..), gSchema)@@ -109,6 +111,28 @@   -- Custom domain reasons.   | CustomReason (DomainReason a)   deriving (Eq, Generic, Show, Typeable, Functor, Foldable, Traversable)++instance Applicative Reason where+  pure = return+  (<*>) = ap++instance Monad Reason where+  return a = CustomReason (DomainReason a)+  r >>= f = case r of+    CustomReason (DomainReason a) -> f a+    UnsupportedRoute              -> UnsupportedRoute+    UnsupportedMethod             -> UnsupportedMethod+    UnsupportedVersion            -> UnsupportedVersion+    IdentError   e                -> IdentError   e+    HeaderError  e                -> HeaderError  e+    ParamError   e                -> ParamError   e+    InputError   e                -> InputError   e+    OutputError  e                -> OutputError  e+    NotFound                      -> NotFound+    NotAllowed                    -> NotAllowed+    AuthenticationFailed          -> AuthenticationFailed+    Busy                          -> Busy+    Gone                          -> Gone  deriveAll ''DataError "PFDataError" deriveAll ''Reason    "PFReason"
src/Rest/Types/Void.hs view
@@ -38,6 +38,15 @@ instance Show Void where   show = magic +instance Eq Void where+  x == _ = magic x++instance Ord Void where+  compare x _ = magic x++instance Read Void where+  readsPrec _ _ = []+ -- | Generic. Can't derive it, sadly.  instance Generic Void where