[Haskell] ANNNOUNCE: lens 3.7 released

Ashley Yakeley ashley at semantic.org
Mon Dec 10 04:14:46 CET 2012


On 07/12/12 02:19, Edward Kmett wrote:

> I am happy to announce the release of version 3.7 of the lens package,
> which provides "Lenses, Folds, and Traversals" for working with
> arbitrary data types.

Do you use types to index the fields of tuples? It's a good general 
mechanism to represent the "tupleness" of certain types. I had a quick 
look and it didn't seem you were doing this.

For instance, consider this type:

  data P = MkP Int Bool Char

If one wants to consider the three fields as separate items, one can 
construct a type that's an index to them:

  data PInd :: * -> * where
    PFirst :: PInd Int
    PSecond :: PInd Bool
    PThird :: PInd Char

It's then straightforward to construct an isomorphism between P and 
"forall a. PInd a -> a". You can also use it to build lenses for the 
fields, etc.

-- Ashley



More information about the Haskell mailing list