What is this abstract data type called?

I write Haskell, but it can be applied to any OO or functional language with the concept of ADT. I will give the template in Haskell, ignoring the fact that arithmetic operators are already accepted:

class Thing a where
   (+) :: a -> a -> a
   (-) :: a -> a -> a
   x - y = x + negate y
   (*) :: (RealFrac b) => a -> b -> a
   negate :: a -> a
   negate x = x * (-1)

Basically, these are things that can be added and subtracted, as well as multiplied by real fractional values. One example would be a simple list of numbers: addition and subtraction in pairs (in Haskell, "(+) = zipWith (+)"), and multiplication by real multiplies each element in the list by the same amount. I met enough other examples to define it as a class, but I don’t know exactly what to call it.

In Haskell, its usually a monoid, provided that there is some kind of null value.

Is this some well-known kind of object in an zoo of algebraic types? I looked through rings, half rings, intimacy, groups, etc., without finding it.

+3
source share
1 answer

This is a vector space: http://en.wikipedia.org/wiki/Vector_space . You have addition and scalar multiplication.

+9
source

Source: https://habr.com/ru/post/1770159/


All Articles