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

Alexander Solla ajs at 2piix.com
Tue Feb 16 21:08:19 EST 2010


On Feb 16, 2010, at 2:11 PM, Stephen Tetley wrote:

> Your monad looks equivalent to the Identity monad but over a much
> bigger syntax. What advantages do you get from it being a monad,
> rather than just a functor?


I replied to Stephen, but forgot to include the list.  I took the  
liberty of making some changes.

I mostly use this construct functorially.  Defining a monad instance  
can be done in O(n) lines, but an applicative functor instance needs  
O(n^2) lines, where n is the number of type constructors.  The monadic  
structure doesn't interfere with the semantics I want, so I went with  
that.

As you said, this is basically an identity monad, but it's not too  
hard to turn it into a sequencing monad.  For example, instead of  
defining (NestViews l m r) >>= f as (NestViews (l >>= f) (m >>= f) (r  
 >>= f)), we can do it in terms of arbitrary constructors, as long as  
 >>= induced a partial order.  This approach has some interesting  
potential.


More information about the Haskell-Cafe mailing list