either-result 0.1.0.0 → 0.1.1.0
raw patch · 5 files changed
+41/−5 lines, 5 filesdep +hspecPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: hspec
API changes (from Hackage documentation)
- Data.Either.Result: data Result a
+ Data.Either.Result: Result :: Either String a -> Result a
+ Data.Either.Result: [runResult] :: Result a -> Either String a
+ Data.Either.Result: newtype Result a
Files
- CHANGELOG.md +6/−0
- either-result.cabal +14/−1
- spec/Data/Either/ResultSpec.hs +16/−0
- spec/Spec.hs +1/−0
- src/Data/Either/Result.hs +4/−4
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Revision history for either-result +## 0.1.1.0++*2020.07.28*++- Expose a value constructor and a field for coercion.+ ## 0.1.0.0 *2020.07.26*
either-result.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: either-result-version: 0.1.0.0+version: 0.1.1.0 synopsis: ‘Result a’ is a wrapper of ‘Either String a’. description: ‘Result a’ is a wrapper of ‘Either String a’, but ‘Result’ is an instance of ‘MonadFail’. homepage: https://github.com/kakkun61/either-result@@ -49,3 +49,16 @@ -rtsopts -with-rtsopts=-N build-tool-depends: doctest-discover:doctest-discover++test-suite spec+ import: common+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ hs-source-dirs: spec+ other-modules: Data.Either.ResultSpec+ build-depends: either-result,+ hspec+ ghc-options: -threaded+ -rtsopts+ -with-rtsopts=-N+ build-tool-depends: hspec-discover:hspec-discover
+ spec/Data/Either/ResultSpec.hs view
@@ -0,0 +1,16 @@+module Data.Either.ResultSpec (spec) where++import Data.Either.Result++import Test.Hspec++import Data.Coerce++spec :: Spec+spec = do+ describe "coercible" $ do+ it "Result Int -> Either String Int" $ do+ let+ actual = coerce $ Success (0 :: Int)+ expected = Right 0 :: Either String Int+ actual `shouldBe` expected
+ spec/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
src/Data/Either/Result.hs view
@@ -11,7 +11,7 @@ -- | @'Result' a@ is a wrapper of @'Either' 'String' a@, but 'Result' is an instance of 'MonadFail'. -- A discussion about 'MonadFail' of 'Either' is <https://gitlab.haskell.org/ghc/ghc/-/issues/12160>. module Data.Either.Result- ( type Result+ ( type Result (Result, runResult) , pattern Error , pattern Success , result@@ -36,7 +36,7 @@ -- | @'Result' a@ is a wrapper of @'Either' 'String' a@. newtype Result a =- Result { either :: Either String a }+ Result { runResult :: Either String a } deriving stock (Eq, Ord, Generic, Functor, Foldable, Traversable) deriving newtype (Semigroup, Applicative, Monad) @@ -116,9 +116,9 @@ fromEither = Result {-# INLINE fromEither #-} --- | Convert @'Either' 'String' a@ from @'Result' a@.+-- | Convert @'Result' a@ to @'Either' 'String' a@. toEither :: Result a -> Either String a-toEither = either+toEither = runResult {-# INLINE toEither #-} -- | Convert @'Result' a@ to @a@ with a default value.