úÎ+¦*?     (c) Dennis Gosnell, 2016BSD-style (see LICENSE file)cdep.illabout@gmail.com experimentalPOSIXNone)+04&Newtype wrapper to be able to provide  and  instances.)Actual error information we want to send.+Additional error information in plain text.&Newtype wrapper to be able to provide  and  instances. Used with  .<Wrapper around either a success or an error. Isomorphic to ..The only interesting part of this type is the  and  instances. YMain type to be used. Wrapper around responses from an API, mainly used with a JSON API.Type synonym around . Wrap an a in a success  .*toSuccessEnvelope 3 :: Envelope String IntEnvelopeSuccess (Success 3) Wrap an a' and an additional message in an error  .VtoErrEnvelope "DB_ERROR" "there was an error with the database" :: Envelope String Int_EnvelopeErr (Err {errErr = "DB_ERROR", errExtra = Just "there was an error with the database"})Wrap an a in an error  .0toErrEnvelope' "DB_ERROR" :: Envelope String Int;EnvelopeErr (Err {errErr = "DB_ERROR", errExtra = Nothing})  Throw an 'Err e' using  in a  that implements . If you have ExceptT ( e)| somewhere inside your monad transformer stacks, this function can be used to throw an error (return early) in a function.'import Control.Monad.Except (runExcept)TthrowEnvelopeErr "BAD_ERROR" "a very bad error occurred!" :: Either (Err String) IntOLeft (Err {errErr = "BAD_ERROR", errExtra = Just "a very bad error occurred!"})-Here is a longer example using a monad stack. ÿtype MyMonadStack = ReaderT Int (ExceptT (Err String) IO) doSomething :: Int -> MyMonadStack Int doSomething int = if int < 0 then throwEnvelopeErr "INT_TOO_SMALL" "the integer passed to doSomething is too small" else return (int + 1) Like  ! but without providing a message.'import Control.Monad.Except (runExcept)TthrowEnvelopeErr "BAD_ERROR" "a very bad error occurred!" :: Either (Err String) IntOLeft (Err {errErr = "BAD_ERROR", errExtra = Just "a very bad error occurred!"})For  e , wrap the e in an object with "extra" and "error" fields..The resulting JSON object will look like this: ! { "extra": ..., "error": .... } For  a , wrap the a in an object with a "data" field..The resulting JSON object will look like this:  { "data": ... } <Tries to parse a successful response. If you are using the  " type synonym, this will use the  instance for .FIf that fails, try to parse an error response. If you are using the  ! type synonym, this will use the  instance for .             !"envel_7OfpFCVWxnDHUPLwK6H3GO Web.EnvelopeErrerrErrerrExtraSuccess Envelope' EnvelopeErrEnvelopeSuccessEnvelopetoSuccessEnvelope toErrEnvelopethrowEnvelopeErrthrowEnvelopeErr'aeson_FnADcKFoDWeK9YK1YvshsyData.Aeson.Types.ClassToJSONFromJSONbase Data.EitherEithertoErrEnvelope'mtl_Aue4leSeVkpKLsfHIV51E8Control.Monad.Error.Class throwErrorGHC.BaseMonad MonadError $fFromJSONErr$fFromJSONSuccess$fFromJSONEnvelope' $fToJSONErr$fToJSONSuccess$fToJSONEnvelope'