File: Spec.hs

package info (click to toggle)
haskell-filtrable 0.1.6.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 100 kB
  • sloc: haskell: 255; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 922 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{-# LANGUAGE PartialTypeSignatures #-}

module Main (main) where

import Prelude hiding (filter)
import Control.Applicative
import Data.Foldable
import Data.Filtrable
import qualified Data.List as List
import Test.SmallCheck
import Test.Tasty
import Test.Tasty.SmallCheck

main :: IO ()
main = defaultMain $ testGroup ""
  [ testGroup "Filtrable"
      [ testProperty "filter" (prop_filter :: _ -> [Maybe Bool] -> _)
      ]
  , testGroup "nub"
      [ testProperty "nub" (prop_nub :: [Int] -> _)
      , testProperty "nubOrd" (prop_nubOrd :: [Int] -> _)
      ] 
  ]

prop_filter :: (Filtrable f, Foldable f) => (a -> Bool) -> f a -> Bool
prop_filter = liftA2 (.) all filter

prop_nub :: (Filtrable f, Traversable f, Eq a) => f a -> Bool
prop_nub = (==) <$> List.nub . toList <*> toList . nub

prop_nubOrd :: (Filtrable f, Traversable f, Ord a) => f a -> Bool
prop_nubOrd = (==) <$> List.nub . toList <*> toList . nubOrd