Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What type of math is this: a -> b -> c

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!

like image 403
bmaddy Avatar asked Mar 27 '11 14:03

bmaddy


People also ask

What is set in math grade 7?

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.

What is set notation math?

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.

What's the formula for algebra?

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.


1 Answers

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).

like image 184
sth Avatar answered Oct 08 '22 12:10

sth