-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Well, no useful properties hold. Should rewrite the type
- Loading branch information
Showing
4 changed files
with
72 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,46 @@ | ||
module Test.Properties | ||
( monofunctorIdentity | ||
, monofunctorCompose | ||
, monoidAssociativity | ||
, monoidLeftIdentity | ||
, semigroupAssociativity | ||
) where | ||
|
||
import Data.MonoTraversable | ||
import Data.Text (Text) | ||
import Prelude (Bool, Eq, id, (.), (==)) | ||
import ClassyPrelude | ||
import Data.Monoid (mappend) | ||
import Data.Semigroup ((<>)) | ||
import Test.QuickCheck | ||
import qualified Test.QuickCheck.Function as QC | ||
|
||
import qualified Fun.Sexp as S | ||
import Test.Instances () | ||
|
||
|
||
type SE = S.Expression Text | ||
|
||
monofunctorIdentity :: Property | ||
monofunctorIdentity = property (prop :: S.Expression Text -> Bool) | ||
monofunctorIdentity = property (prop :: SE -> Bool) | ||
where | ||
prop :: (MonoFunctor f, Eq f) => f -> Bool | ||
prop f = omap id f == f | ||
|
||
monofunctorCompose :: Property | ||
monofunctorCompose = property (prop :: QC.Fun Text Text -> QC.Fun Text Text -> S.Expression Text -> Bool) | ||
monofunctorCompose = property (prop :: QC.Fun Text Text -> QC.Fun Text Text -> SE -> Bool) | ||
where | ||
prop :: (MonoFunctor f, Eq f) => QC.Fun (Element f) (Element f) -> QC.Fun (Element f) (Element f) -> f -> Bool | ||
prop (QC.Fun _ f) (QC.Fun _ g) x = (omap g (omap f x)) == (omap (g . f) x) | ||
|
||
monoidAssociativity :: Property | ||
monoidAssociativity = property (prop :: SE -> SE -> SE -> Bool) | ||
where | ||
prop x y z = (x `mappend` y) `mappend` z == x `mappend` (y `mappend` z) | ||
|
||
monoidLeftIdentity :: Property | ||
monoidLeftIdentity = property (prop :: SE -> Bool) | ||
where | ||
prop x = mempty `mappend` x == x | ||
|
||
semigroupAssociativity :: Property | ||
semigroupAssociativity = property (prop :: SE -> SE -> SE -> Bool) | ||
where | ||
prop x y z = (x <> y) <> z == x <> (y <> z) |