diff --git a/.gitignore b/.gitignore index 7118223..f944940 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /.cabal-sandbox /cabal.sandbox.config /.stack-work +/stack.yaml.lock # Temporary files. *~ diff --git a/.travis.yml b/.travis.yml index 6bcf8ba..63a533a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ --- language: generic +dist: xenial +os: linux cache: directories: @@ -7,11 +9,11 @@ cache: before_install: - export PATH=$HOME/.local/bin:$PATH - - travis_retry curl -L https://github.com/TokTok/hs-tools/releases/download/v0.1/hs-tools-v0.1.tar.gz | tar xz -C $HOME + - travis_retry curl -L https://github.com/TokTok/hs-tools/releases/download/v0.6/hs-tools-v0.6.tar.gz | tar xz -C $HOME script: - hlint . - stylish-haskell-lhs -i . - git diff --exit-code - travis_wait stack --no-terminal test --coverage - - shc data-msgpack testsuite + - shc msgpack-binary testsuite diff --git a/BUILD.bazel b/BUILD.bazel index f6e829d..92a08d8 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -3,16 +3,14 @@ load("@rules_haskell//haskell:defs.bzl", "haskell_library") load("//third_party/haskell/hspec-discover:build_defs.bzl", "hspec_test") load("//tools/project:build_defs.bzl", "project") -project( - license = "hs-msgpack", -) +project(license = "hs-msgpack") haskell_library( - name = "hs-msgpack", + name = "hs-msgpack-binary", srcs = glob(["src/**/*.*hs"]), compiler_flags = ["-Wno-unused-imports"], src_strip_prefix = "src", - version = "0.0.12", + version = "0.0.14", visibility = ["//visibility:public"], deps = [ "//hs-msgpack-types", @@ -25,10 +23,11 @@ haskell_library( ) hspec_test( - name = "test", + name = "testsuite", + size = "small", compiler_flags = ["-Wno-unused-imports"], deps = [ - ":hs-msgpack", + ":hs-msgpack-binary", "//hs-msgpack-types", hazel_library("QuickCheck"), hazel_library("base"), diff --git a/data-msgpack.cabal b/msgpack-binary.cabal similarity index 91% rename from data-msgpack.cabal rename to msgpack-binary.cabal index 55a568c..a9b4a12 100644 --- a/data-msgpack.cabal +++ b/msgpack-binary.cabal @@ -1,5 +1,5 @@ -name: data-msgpack -version: 0.0.13 +name: msgpack-binary +version: 0.0.14 synopsis: A Haskell implementation of MessagePack homepage: http://msgpack.org/ license: BSD3 @@ -39,7 +39,7 @@ library , binary >= 0.7.0.0 , bytestring , data-binary-ieee754 - , data-msgpack-types >= 0.0.1 && < 0.1.0 + , msgpack-types >= 0.0.1 && < 0.1.0 , text executable msgpack-parser @@ -49,12 +49,12 @@ executable msgpack-parser ghc-options: -Wall -fno-warn-unused-imports + main-is: msgpack-parser.hs build-depends: base < 5 , bytestring , groom - , data-msgpack - main-is: msgpack-parser.hs + , msgpack-binary test-suite testsuite type: exitcode-stdio-1.0 @@ -71,14 +71,13 @@ test-suite testsuite , QuickCheck , bytestring , containers - , data-msgpack - , data-msgpack-types , hashable , hspec + , msgpack-binary + , msgpack-types , text , unordered-containers , vector - , void benchmark benchmark type: exitcode-stdio-1.0 @@ -96,5 +95,5 @@ benchmark benchmark , QuickCheck , bytestring , criterion - , data-msgpack , deepseq + , msgpack-binary diff --git a/stack.yaml b/stack.yaml index 2e29414..1887509 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,6 +1,5 @@ --- packages: [.] -resolver: lts-6.27 +resolver: lts-14.27 extra-deps: - - QuickCheck-2.9.2 - - data-msgpack-types-0.0.2 + - msgpack-types-0.0.4 diff --git a/test/Data/MessagePackSpec.hs b/test/Data/MessagePackSpec.hs index 462ea14..06abf62 100644 --- a/test/Data/MessagePackSpec.hs +++ b/test/Data/MessagePackSpec.hs @@ -6,29 +6,29 @@ module Data.MessagePackSpec where import Test.Hspec import Test.QuickCheck -import qualified Test.QuickCheck.Gen as Gen - -import Control.Applicative ((<$>), (<*>)) -import qualified Data.ByteString.Char8 as S -import qualified Data.ByteString.Lazy as L8 -import qualified Data.ByteString.Lazy.Char8 as L -import Data.Hashable (Hashable) -import qualified Data.HashMap.Strict as HashMap -import Data.Int (Int16, Int32, Int64, Int8) -import qualified Data.IntMap as IntMap -import qualified Data.Map as Map -import qualified Data.Maybe as Maybe -import qualified Data.Text.Lazy as LT -import qualified Data.Vector as V -import qualified Data.Vector.Storable as VS -import qualified Data.Vector.Unboxed as VU -import Data.Void (Void) -import Data.Word (Word, Word16, Word32, Word64, - Word8) -import GHC.Generics (Generic) +import qualified Test.QuickCheck.Gen as Gen + +import Control.Applicative ((<$>), (<*>)) +import qualified Data.ByteString.Char8 as S +import qualified Data.ByteString.Lazy as L8 +import qualified Data.ByteString.Lazy.Char8 as L +import Data.Hashable (Hashable) +import qualified Data.HashMap.Strict as HashMap +import Data.Int (Int16, Int32, Int64, Int8) +import qualified Data.IntMap as IntMap +import qualified Data.Map as Map +import qualified Data.Maybe as Maybe +import qualified Data.Result as R +import qualified Data.Text.Lazy as LT +import qualified Data.Vector as V +import qualified Data.Vector.Storable as VS +import qualified Data.Vector.Unboxed as VU +import Data.Void (Void) +import Data.Word (Word, Word16, Word32, Word64, + Word8) +import GHC.Generics (Generic) import Data.MessagePack -import qualified Data.MessagePack.Types.Result as R data Unit = Unit @@ -324,8 +324,6 @@ spec = do property $ \(a :: IntMap.IntMap Int) -> a `shouldBe` mid a it "HashMap String Int" $ property $ \(a :: HashMap.HashMap String Int) -> a `shouldBe` mid a - it "Option Int" $ - property $ \(a :: Option Int) -> a `shouldBe` mid a it "maybe int" $ property $ \(a :: Maybe Int) -> a `shouldBe` mid a it "maybe nil" $ diff --git a/test/Data/Result.hs b/test/Data/Result.hs new file mode 100644 index 0000000..abd4850 --- /dev/null +++ b/test/Data/Result.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE Safe #-} +module Data.Result + ( Result (..) + ) where + +import Control.Applicative (Applicative (..), (<$>), (<*>)) +import Control.Monad.Fail (MonadFail (..)) + +data Result a + = Success a + | Failure String + deriving (Read, Show, Eq, Functor) + +instance Applicative Result where + pure = Success + + Success f <*> x = fmap f x + Failure msg <*> _ = Failure msg + +instance Monad Result where + return = Success + fail = Failure + + Success x >>= f = f x + Failure msg >>= _ = Failure msg + +instance MonadFail Result where + fail = Failure diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index 22baf49..db610b4 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel @@ -6,7 +6,7 @@ haskell_binary( srcs = ["msgpack-parser.hs"], compiler_flags = ["-Wno-unused-imports"], deps = [ - "//hs-msgpack", + "//hs-msgpack-binary", hazel_library("base"), hazel_library("bytestring"), hazel_library("groom"),