Skip to content

Commit

Permalink
Merge pull request #258 from phadej/functionVoid
Browse files Browse the repository at this point in the history
Add functionVoid
  • Loading branch information
nick8325 committed Jun 11, 2019
2 parents 2a7a43f + 677833d commit a151d28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Test/QuickCheck.hs
Expand Up @@ -171,6 +171,7 @@ module Test.QuickCheck
, functionIntegral
, functionRealFrac
, functionBoundedEnum
, functionVoid
#endif

-- * The 'CoArbitrary' typeclass: generation of functions the old-fashioned way
Expand Down
10 changes: 9 additions & 1 deletion Test/QuickCheck/Function.hs
@@ -1,4 +1,4 @@
{-# LANGUAGE TypeOperators, GADTs, CPP #-}
{-# LANGUAGE TypeOperators, GADTs, CPP, Rank2Types #-}
#ifndef NO_SAFE_HASKELL
{-# LANGUAGE Safe #-}
#endif
Expand Down Expand Up @@ -48,6 +48,7 @@ module Test.QuickCheck.Function
, functionIntegral
, functionRealFrac
, functionBoundedEnum
, functionVoid
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708
, pattern Fn
, pattern Fn2
Expand Down Expand Up @@ -174,6 +175,13 @@ functionIntegral = functionMap fromIntegral fromInteger
functionShow :: (Show a, Read a) => (a->c) -> (a:->c)
functionShow f = functionMap show read f

-- | Provides a 'Function' instance for types isomorphic to 'Data.Void.Void'.
--
-- An actual @'Function' 'Data.Void.Void'@ instance is defined in
-- @quickcheck-instances@.
functionVoid :: (forall b. void -> b) -> void :-> c
functionVoid _ = Nil

-- | The basic building block for 'Function' instances.
-- Provides a 'Function' instance by mapping to and from a type that
-- already has a 'Function' instance.
Expand Down

0 comments on commit a151d28

Please sign in to comment.