Oleg, 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 automatically monoids. Kevin On Oct 9, 2:28 pm, Kevin Jardine <kevinjard...@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. > > Kevin > > On Oct 9, 1:50 pm, Bartek Æwik³owski <paczesi...@gmail.com> wrote: > > > Hello Kevin, > > > 2010/10/9 Kevin Jardine <kevinjard...@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...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > haskell-c...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe