[Haskell-cafe] Need ideas how to model the lack of something

Roman Cheplyaka roma at ro-che.info
Sun Dec 13 21:36:08 UTC 2015

You may want to specify:

1. whether you want the symmetry to be present in the API, the internal
representation, or both
2. what exactly your C type is lacking. It looks like a valid model of
what you described, even if somewhat object-oriented one.

You may also be interested in combinatorial species. That theory
specifically considers functorial shapes containing a specific number of
holes and/or elements. I think Brent Yorgey has some articles and/or
code relating species to Haskell.

On 12/13/2015 10:15 PM, martin wrote:
> Hello all,
> here is a problem where I did not manage to find a suitable abstraction. The main idea goes like this:
> a List (and many other containers) can be seen as something containing "stuff". There is a function (:) that
> unconditionally adds an element to the container and returns a new container
> Now suppose the container has the possiblility to refuse having another element added to it, e.g. because it has only
> limited "space". In that case the corresponding function would have a signature of insert :: a -> C a -> Maybe (C a). If
> an item can successfully be added, then the returned container will be less space avaiable.
> I'd like stuff and space to be symmetrical (maybe there lies the first flaw, because I can enumerate the elements, but I
> cannot enumerate the space). A symmetry like electrones and holes.
> I started like this
> data C a = C {
>             insert :: a -> Maybe (C a),
>             remove :: Maybe (a, C a)
>         }
> but I could not implement anything sensible on top of this.
> I'd be happy to hear any comments on this, including loud thinking and random ramblings.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> .

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151213/14c73d3f/attachment.sig>

More information about the Haskell-Cafe mailing list