Created
March 1, 2019 07:07
-
-
Save HirotoShioi/98f05389933992dc0e0e88c3a31d0569 to your computer and use it in GitHub Desktop.
Working example of validity library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-| | |
-- dependencies: | |
-- - base >= 4.7 && < 5 | |
-- - validity | |
-- - hspec | |
-- - genvalidity | |
-- - genvalidity-hspec | |
-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE TypeApplications #-} | |
module Lib where | |
import Data.GenValidity (GenUnchecked, GenValid, Validity) | |
import GHC.Generics (Generic) | |
import Test.Hspec (hspec) | |
import Test.Validity (eqSpec, genValidSpec) | |
data MyType = MyType | |
{ myBool :: Bool | |
, myRational :: Rational | |
} deriving (Show, Eq, Generic) | |
instance Validity MyType | |
instance GenUnchecked MyType | |
instance GenValid MyType | |
spec :: IO () | |
spec = hspec $ do | |
eqSpec @MyType | |
genValidSpec @MyType |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment