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

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Thu Feb 19 03:08:58 UTC 2015


On 19 February 2015 at 14:00, Stuart Hungerford
<stuart.hungerford at gmail.com> wrote:
> On Thu, Feb 19, 2015 at 12:13 PM,  <haskell-cafe-request at haskell.org> wrote:
>
>> From: Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk>
>> To: haskell-cafe at 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 at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list