I often see type declarations similar to this when looking at Haskell:
a -> (b -> c)
I understand that it describes a function that takes in something of type a and returns a new function that takes in something of type b and returns something of type c. I also understand that types are associative (edit: I was wrong about this - see the comments below), so the above could be rewritten like this to get the same result:
(a -> b) -> c
This would describe a function that takes in something of type a and something of type b and returns something of type c.
I've also heard that you can make a complement (edit: really, the word I was looking for here is dual - see the comments below) to the function by switching the arrows:
a <- b <- c
which I think is equivalent to
c -> b -> a
but I'm not sure.
My question is, what is the name of this kind of math? I'd like to learn more about it so I can use it to help me write better programs. I'm interested in learning things like what a complimentary function is, and what other transformations can be performed on type declarations.
Thanks!
A set is a collection of unique objects i.e. no two objects can be the same. Objects that belong in a set are called members or elements.
Set notation is used in mathematics to essentially list numbers, objects or outcomes. Set notation uses curly brackets { } which are sometimes referred to as braces. Objects placed within the brackets are called the elements of a set, and do not have to be in any specific order.
Basic Algebra Formula a2 + b2 = (a – b)2 + 2ab. (a – b)2 = a2 – 2ab + b. (a + b + c)2 = a2 + b2 + c2 + 2ab + 2ac + 2bc. (a – b – c)2 = a2 + b2 + c2 – 2ab – 2ac + 2bc.
Type declarations are not associative, a -> (b -> c)
is not equivalent to (a -> b) -> c
. Also, you can't "switch" the arrows, a <- b <- c
is not valid syntax.
The usual reference to associativity is in this case that ->
it right associative, which means that a -> b -> c
is interpreted as a -> (b -> c)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With