Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the reason behind the name Market in Control.Lens?

Edward Kmett's optics library; Control.Lens defines a large number of types.

Most of these have relatively self explanatory names, like Traversal and Fold.

It also defines some types with less obvious names, like Bazaar

From the Bazaar page:

a.k.a. indexed Cartesian store comonad, indexed Kleene store comonad, or an indexed FunList.

...

Mnemonically, a Bazaar holds many stores and you can easily add more.

I can't figure out the reasoning behind the name of the type Market. I assume that this is somehow also related to store monads/comonads? Is this correct?

like image 872
Joe Avatar asked Aug 19 '19 08:08

Joe


1 Answers

I am not privvy to the true history, but I suspect the following. Let's line up the types this way:

Market' a s t: Market (a -> t) (s -> Either t a)
Store   a   t: Store  (a -> t)                a

So: a Market a s t is a bit like a collection of Store a ts indexed by s. Indeed, if you choose a particular s, then your Market' a s t becomes one of these two things:

  1. The s -> Either t a returns a thing tagged by Right, so you have an a -> t and an a. This is exactly the same as a Store a t.
  2. The s -> Either t a returns a thing tagged by Left. You have gotten yourself most of the way to a store: you have an a -> t, but instead of having a particular index a that function can be applied to, you have your hands directly on the t that would result. (N.B. I don't see any reason to believe that the t is necessarily in the codomain of the a -> t. I'm just giving an intuition for the name, not behavioral laws.)

I think it's okay: real-world markets often have things that are similar to but not quite exactly stores in them, too. =)

like image 72
Daniel Wagner Avatar answered Oct 21 '22 20:10

Daniel Wagner