Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build without warnings on 7.10 #58

Merged
merged 1 commit into from Dec 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 18 additions & 6 deletions test/Test/P/Applicative.hs
@@ -1,15 +1,27 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Test.P.Applicative where

import Control.Applicative ((<$>), pure)

import Data.Bool (Bool(..))
import Data.Function (($))
import Data.Functor.Identity (Identity(..))
import Data.Int (Int)
import Data.Maybe (Maybe(..))
import Data.Monoid (Sum(..))

import P.Applicative
import Control.Applicative
import Data.Monoid
import Data.Functor.Identity

import Prelude (Eq(..))

import System.IO (IO)

import Test.QuickCheck
import Test.QuickCheck.Property.Monoid (prop_Monoid, T(..))
import Test.QuickCheck.Property.Common (eq)
Expand Down Expand Up @@ -41,6 +53,6 @@ instance Arbitrary (m a) => Arbitrary (ApplicativeMonoid m a) where
instance Arbitrary a => Arbitrary (Sum a) where
arbitrary = Sum <$> arbitrary

return []
pure []
tests :: IO Bool
tests = $quickCheckAll
28 changes: 19 additions & 9 deletions test/Test/P/Foldable.hs
Expand Up @@ -2,27 +2,37 @@
{-# LANGUAGE TemplateHaskell #-}
module Test.P.Foldable where

import Control.Applicative ( pure )
import Control.Monad.State
import Control.Applicative (pure)
import Control.Monad.State (StateT(..), State, runState)

import Data.Bool (Bool)
import Data.Either (Either(..))
import Data.Function (($), const)
import Data.Int (Int)
import qualified Data.List as List
import Data.Maybe (Maybe(..))

import P.Foldable

import Prelude (Eq(..), Num(..))

import System.IO (IO)

import Test.QuickCheck

import Prelude hiding ( head )

prop_findMapM_first :: Int -> [Int] -> Property
prop_findMapM_first x xs =
runState (findMapM found (x : xs)) 0 === (Just $ x * 2, 1)

prop_findMapM_last :: Int -> [Int] -> Property
prop_findMapM_last x xs = notElem x xs ==>
prop_findMapM_last x xs = List.notElem x xs ==>
let f z = if z == x then found z else notfound
in runState (findMapM f (xs ++ [x])) 0 === (Just $ x * 2, length xs + 1)
in runState (findMapM f (xs List.++ [x])) 0 === (Just $ x * 2, List.length xs + 1)

prop_findMapM_effects :: [Int] -> Property
prop_findMapM_effects xs =
runState (findMapM (const notfound) xs) 0 === (Nothing, length xs)
runState (findMapM (const notfound) xs) 0 === (Nothing, List.length xs)


prop_head_either_left :: Int -> Property
Expand All @@ -38,12 +48,12 @@ prop_head_list_empty :: Property
prop_head_list_empty = head ([] :: [Int]) === Nothing

found :: Int -> State Int (Maybe Int)
found z = StateT $ \n -> return (Just $ z * 2, n + 1)
found z = StateT $ \n -> pure (Just $ z * 2, n + 1)

notfound :: State Int (Maybe Int)
notfound = StateT $ \n -> return (Nothing, n + 1)
notfound = StateT $ \n -> pure (Nothing, n + 1)


return []
pure []
tests :: IO Bool
tests = $quickCheckAll