Function types
Closed this issue · 6 comments
It would be awesome to be able to do something like this:
require(lambda.r)
Function(x) %when% { is.function(x) } %as% x
addn.factory(n) %::% numeric : Function(numeric : numeric)
addn.factory(n) %as% {
addn = function(x) {
x + n
}
Function(addn)
}
It's also worth pointing out that
addn.factory(n) %::% numeric : function
would lead to an error, since function
is a type, but also a function.
There's a special type called Function
that maps to the function
type to avoid this situation. See my package lambda.tools
for examples. Adding type awareness to the function is too much for lambda.r. I am thinking about a new meta language specifically for data science that would include this stuff, but it's still early days in working it out.
Very interesting. Is it a meta language implemented in R, or a brand new language?
It would be similar in concept to a language in the JVM except it would compile into R byte code. The idea is to take the good bits of various functional languages, along with some analysis-specific features, and roll it into a new syntax that is easier to use and faster to implement mathematical ideas.
Sounds interesting. Sort of like clojure for R?
Do you have a repo for it on github?
Yes, along the same lines. No repo yet as it's still in the planning phase. I have some thoughts on using Hindley-Milner type inference for automatic inference of scientific units but need to work out the details.