Re: [Haskell-cafe] Haskell-Cafe Digest, Vol 138, Issue 30

On Thu, Feb 19, 2015 at 12:13 PM,
From: Tom Ellis
To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Testing polymorphic properties with QuickCheck
I'm not quite sure what you're asking specifically, but maybe this will help:
{-# LANGUAGE ScopedTypeVariables #-}
monoid_suite :: forall m. (Eq m, Monoid m) => String -> Proxy m -> TestTree monoid_suite typename _ = testGroup "monoid" [ testProperty ("left additive identity (" ++ typename ++ ")") (prop_left_add_id :: m -> Bool),
... <other general monoid properties here> ]
monoid_suite_integer :: TestTree monoid_suite_integer = monoid_suite "Integer" (Proxy :: Integer)
Please excuse my ignorance as a relatively new Haskell user but is there anything special about that "Proxy m" type? Thanks, Stu

On 19 February 2015 at 14:00, Stuart Hungerford
On Thu, Feb 19, 2015 at 12:13 PM,
wrote: From: Tom Ellis
To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Testing polymorphic properties with QuickCheck I'm not quite sure what you're asking specifically, but maybe this will help:
{-# LANGUAGE ScopedTypeVariables #-}
monoid_suite :: forall m. (Eq m, Monoid m) => String -> Proxy m -> TestTree monoid_suite typename _ = testGroup "monoid" [ testProperty ("left additive identity (" ++ typename ++ ")") (prop_left_add_id :: m -> Bool),
... <other general monoid properties here> ]
monoid_suite_integer :: TestTree monoid_suite_integer = monoid_suite "Integer" (Proxy :: Integer)
Please excuse my ignorance as a relatively new Haskell user but is there anything special about that "Proxy m" type?
No: Proxy is used when you need/want to pass a type around but don't have a value of that type to use. See http://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Proxy.html
Thanks,
Stu _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com http://IvanMiljenovic.wordpress.com
participants (2)
-
Ivan Lazar Miljenovic
-
Stuart Hungerford