[Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references

Heinrich Apfelmus apfelmus at quantentunnel.de
Mon Feb 22 11:53:17 EST 2010

Alexander Solla wrote:
> Yup, that's a type error.  I mean to fold the View (in this case a
> ConcatView) into a monoid.  I think I meant
>    foldMap renderXHtml (ConcatViews l r)

Hm, that would require a type

    renderXHtml :: Monoid t => View t -> Html

>> Your intention reminds me of the use of type variables to get
>> functor-like behavior for free, like in
>>    data RGB' a = RGB a a a   -- auxiliary type constructor
>>    type RGB = RGB' Int       -- what we're interested in
>> but I don't quite see what you're doing with the free monad here,
>> Alexander?
> As you noticed, I am seeking that functorial behavior in order to gain
> some genericity.  bind and return do encode some logic about the nature
> of monadic adjunction, which I am relying on theoretically.  I could
> have used a Functor instance just as easily, but I would have lost my
> "intention" of defining co-equalizers implicitly. 
> (http://en.wikipedia.org/wiki/Beck%27s_monadicity_theorem)

I don't know, the new  ReturnView  constructor which gives rise to the
monad does allow us to represent "views with variables". But to me, this
doesn't seem to add much genericity.

Heinrich Apfelmus


More information about the Haskell-Cafe mailing list