[Haskell-cafe] Re: Polyvariadic functions operating with a monoid

Kevin Jardine kevinjardine at gmail.com
Sun Oct 10 02:26:19 EDT 2010


Hi Brandon,

True, when I replace [] with [""], I get a different error message:

 No instance for (PolyVariadic [[Char]] (WMonoid String))

which now looks a bit like the Int example. In both cases, GHC appears
to be unable to derive the appropriate instance of PolyVariadic. Why
this is so, but worked for Oleg's specific example. is still not clear
to me.

Kevin

On Oct 9, 11:51 pm, Brandon S Allbery KF8NH <allb... at ece.cmu.edu>
wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 10/9/10 10:25 , Kevin Jardine wrote:
>
> > instance Show a => Monoidable a [String] where
> >     toMonoid a = [show a]
>
> > main = putStrLn $ unwrap $ polyToMonoid [] True () (Just (5::Int))
>
> > fails to compile.
>
> > Why would that be? My understanding is that all lists are
> > automatically monoids.
>
> I *think* the problem here is that Oleg specifically pointed out that the
> first parameter to polyToMonoid must specify the type of the monoid.  []
> tells you it's a list, therefore a monoid, but it doesn't say enough to
> allow the [String] instance to be chosen.  (No, the fact that you only
> declared an instance for [String] isn't really enough.)
>
> - --
> brandon s. allbery     [linux,solaris,freebsd,perl]      allb... at kf8nh.com
> system administrator  [openafs,heimdal,too many hats]  allb... at ece.cmu.edu
> electrical and computer engineering, carnegie mellon university      KF8NH
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.10 (Darwin)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkyw49wACgkQIn7hlCsL25VZygCfVETk+3AZ3gKoBy4pZ7j8g4Km
> WXgAnjrbO9rEl2HnQtGQ31EyRuhWzI4r
> =YMDw
> -----END PGP SIGNATURE-----
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-C... at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list