2,083 karma · joined September 27, 2015
Dependent types allow you to express things such as `a == b` as a type, and proving that requires some work, but you don't need any of that at all. Idris is a superset of Haskell, you may say.
So, in short, remember the Pirate Bay idea of putting drones around the world to host their sites, allowing it to stay up forever without censure? Moon does exactly that, without the drones of course.
On doing that in Idris (which is my dream language - the only reason I don't use it is its JS compiler is too slow), would it be possible to randomly generate elements of any data type, or would we have to write an `Arbitrary` instance for every type you want to test? I don't know/remember much about generics on Idris, would love to learn more.
(Seriously, though, why is the JS compiler still so slow? Again - I'm willing to put substantial money into funding a better one...)
Just kidding! A type system, in essence, is not much different from that, though - Pi, for example, is basically a type-level lambda that is applied to the typed function (and it is sufficient to express basically any real-world type system). In any case, I hope I made it very clear on the that it is in no means an actual type system, but my dirty way to get invariants and some refined types on plain JS. If we had a mature Idris->JS compiler this hack wouldn't be necessary. ):
R5RS, the simplest used spec of Scheme, takes dozens of page to merely describe the language. The λ-calculus can be described and implemented in a paragraph. That makes it much easier to create new backends, for example.
About the performance of the program itself, yes, λcalculus is faster than Scheme, by an order of magnitude, sometimes. For one, algorithms on church-encoded lists fuse by reduction, which means that the code below, in Caramel:
map f (filter cond (zipWith (+) (map f a) (map f b)))
fuses to a single tight loop - i.e., it iterates through the lists `a` and `b` only once, and returns the result after that, creating no intermediate structure. Scheme would create 4 intermediate structures on this case. Since it is already 2~3x slower than the λ-calculus (running on GHC), that'd make it an order of magnitude slower in that case.