mixed-types-num 0.5.0.1 → 0.5.0.2
raw patch · 3 files changed
+25/−22 lines, 3 files
Files
- mixed-types-num.cabal +2/−2
- src/Numeric/MixedTypes/Kleenean.hs +12/−3
- test/Numeric/MixedTypes/BoolSpec.hs +11/−17
mixed-types-num.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: c571e2a889134066ae334e92527480bdc09db3eb49d6461c334c9184aa34be43+-- hash: 3aadc479d775f322f55525a75972a2550f7039783922118344addf7514671100 name: mixed-types-num-version: 0.5.0.1+version: 0.5.0.2 synopsis: Alternative Prelude with numeric and logic expressions typed bottom-up description: Please see the README on GitHub at <https://github.com/michalkonecny/mixed-types-num#readme> category: Math
src/Numeric/MixedTypes/Kleenean.hs view
@@ -1,4 +1,5 @@ {-# OPTIONS_GHC -Wno-orphans #-}+{-# LANGUAGE DeriveGeneric #-} {-| Module : Numeric.MixedType.Kleenean Description : Three-valued logic@@ -12,15 +13,18 @@ -} module Numeric.MixedTypes.Kleenean (- Kleenean(..), kleenean+ Kleenean(..), kleenean, tKleenean ) where import Numeric.MixedTypes.PreludeHiding import qualified Prelude as P +import Test.SmallCheck.Series+import GHC.Generics+ import Numeric.MixedTypes.Literals- ( ConvertibleExactly(..), convertExactly )+ ( ConvertibleExactly(..), convertExactly, T(T) ) import Numeric.MixedTypes.Bool ( (&&), not,@@ -29,8 +33,13 @@ CanTestCertainly(..), and ) +tKleenean :: T Kleenean+tKleenean = T "Kleenean"+ data Kleenean = CertainTrue | CertainFalse | TrueOrFalse- deriving (P.Eq, Show)+ deriving (P.Eq, Show, Generic)++instance Serial IO Kleenean type CanBeKleenean t = ConvertibleExactly t Kleenean kleenean :: (CanBeKleenean t) => t -> Kleenean
test/Numeric/MixedTypes/BoolSpec.hs view
@@ -18,21 +18,15 @@ spec :: Spec spec = do specIsBool tBool- specIsBool tMaybeBool- specIsBool tMaybeMaybeBool+ specIsBool tKleenean -- mixed-type tests:- specCanAndOr tBool tMaybeBool tBool- specCanAndOr tMaybeMaybeBool tMaybeBool tBool- describe "mixed-type Boolean operation examples" $ do- it "can do True || Just False" $ do- True || Just False `shouldBe` Just True- it "can do True || Nothing" $ do- True || (Nothing :: Maybe Bool) `shouldBe` Just True- it "can do Nothing || True" $ do- (Nothing :: Maybe Bool) || True `shouldBe` Just True- it "can do True || Just (Just False)" $ do- True || Just (Just False) `shouldBe` Just (Just True)- it "can do True || Just Nothing" $ do- True || Just (Nothing :: Maybe Bool) `shouldBe` Just (Just True)- it "can do Just Nothing || True" $ do- Just (Nothing :: Maybe Bool) || True `shouldBe` Just (Just True)+ specCanAndOr tBool tKleenean tBool+ -- describe "mixed-type Boolean operation examples" $ do+ -- it "can do True || Nothing" $ do+ -- True || (Nothing :: Maybe Bool) `shouldBe` Just True+ -- it "can do Nothing || True" $ do+ -- (Nothing :: Maybe Bool) || True `shouldBe` Just True+ -- it "can do True || Just Nothing" $ do+ -- True || Just (Nothing :: Maybe Bool) `shouldBe` Just (Just True)+ -- it "can do Just Nothing || True" $ do+ -- Just (Nothing :: Maybe Bool) || True `shouldBe` Just (Just True)