<p>It is possible to construct recursive datatypes (algebraic datatypes are a special case) in a suitable category of complete metric spaces, see for instance P. America and J. Rutten's <a href="https://homepages.cwi.nl/~janr/papers/files-of-papers/1989-JCSS.pdf" rel="nofollow noreferrer">Solving Reflexive Domain Equations in a Category of Complete Metric Spaces</a>, Journal of Computer and System Sciences 39, 343-375 (1989).</p>

<p>As for making vector spaces out of algebraic datatypes, I do not really know, but if you explain what you want them for, we might be able to suggest something.</p>

CC BY-SA 4.0
2018-07-31T13:54:05.770Z
2018-07-31T13:54:05.770Z
Andrej Bauer
<p>I have a recursive algebraic datatype. I (somewhat arbitrarily) defined one function to compute distance between instances, and am trying to define a function to approximate a "vector" between instances.  I assume there's no single way to define a metric space on top of a definition of an algebraic data type, much less a vector space, but was wondering what literature exists about treating recursive algebraic datatypes as existing in a topological space with meaningful comparisons.</p>

<p>The reason I want to treat it like a vector space is because I want to define interpolation between two structures in some reasonable manner.  </p>

CC BY-SA 4.0
2018-07-31T13:48:24.703Z
What do you need these structures for? That might direct possible choices in a useful way. They yearning for vectors makes it look like you're secretly doing machine learning.
Andrej Bauer
CC BY-SA 4.0
2018-07-31T16:56:35.487Z
Haha, I do come from something of a machine learning background, so maybe that shows through!
lightning
<ds.data-structures><functional-programming><topology>
Topology/Space of Recursive Algebraic Datatypes
lightning
# Topology/Space of Recursive Algebraic Datatypes

(Asked by: username_0 on 2018-07-30)

I have a recursive algebraic datatype. I (somewhat arbitrarily) defined one function to compute distance between instances, and am trying to define a function to approximate a "vector" between instances. I assume there's no single way to define a metric space on top of a definition of an algebraic data type, much less a vector space, but was wondering what literature exists about treating recursive algebraic datatypes as existing in a topological space with meaningful comparisons.

The reason I want to treat it like a vector space is because I want to define interpolation between two structures in some reasonable manner.

**Tags:** ds.data-structures, functional-programming, topology

> **Comments:**
> **username_1**: What do you need these structures for? That might direct possible choices in a useful way. They yearning for vectors makes it look like you're secretly doing machine learning.  
> **username_0**: Haha, I do come from something of a machine learning background, so maybe that shows through!  

---

## 1 answers

### Answer by username_1 on 2018-07-31. Score: 1

It is possible to construct recursive datatypes (algebraic datatypes are a special case) in a suitable category of complete metric spaces, see for instance P. America and J. Rutten's [Solving Reflexive Domain Equations in a Category of Complete Metric Spaces](https://homepages.cwi.nl/~janr/papers/files-of-papers/1989-JCSS.pdf), Journal of Computer and System Sciences 39, 343-375 (1989).

As for making vector spaces out of algebraic datatypes, I do not really know, but if you explain what you want them for, we might be able to suggest something.


---

