[Haskell-cafe] Re: Polyvariadic functions operating with a monoid
kevinjardine at gmail.com
Sat Oct 9 10:25:10 EDT 2010
Another puzzle is that:
instance Show a => Monoidable a String where
toMonoid a = show a
main = putStrLn $ unwrap $ polyToMonoid "" True () (Just (5::Int))
works just fine, but
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
On Oct 9, 2:28 pm, Kevin Jardine <kevinjard... at gmail.com> wrote:
> Hi Bartek,
> Yes, it compiles, but when I try to use polyToMonoid', it turns out
> that this function is no longer polyvariadic, unlike the original
> polyToMonoid .
> This may be what Luke meant when he wrote "you lose composability".
> Even with the extra unwrap function I think that this is pretty cool,
> but I would ideally like to hide the unwrap.
> On Oct 9, 1:50 pm, Bartek Æwik³owski <paczesi... at gmail.com> wrote:
> > Hello Kevin,
> > 2010/10/9 Kevin Jardine <kevinjard... at gmail.com>:
> > > I was attempting to turn this into a small library and wanted to avoid
> > > exporting unwrap.
> > > I defined:
> > > polyToMonoid' = unwrap . polyToMonoid
> > If you disable MonomorphismRestriction this definition typechecks just
> > fine. Alternatively, you can ask ghci about the type of "unwrap .
> > polyToMonoid" and paste that into the type sig.
> > regards,
> > Bartek Æwik³owski
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-C... at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe
> Haskell-Cafe mailing list
> Haskell-C... at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe