by laureny · 12y ago · 0 comments
> This is why we hear that Haskell reprise if it compiles, it works.
If this were true then functions would not need bodies, you would just define their signatures and move on with life.
The truth is that even with its superb type system, Haskell still needs to run your code. Your code might be statically correct but its runtime is up to you.
I would prefer it if people rephrased this claim like "If it compiles in Haskell, it's more likely to run than if it compiles in Java".
More honest.
This is already possible sometimes in Haskell so long as we restrict ourselves from pathological values like exceptions and non-termination. In fact, the first place this phrase shows up is Russel O'Connor talking about highly polymorphic lens code.
http://r6.ca/blog/20120708T122219Z.html
This kind of type limitation of possible implementations is called parametricity and is difficult to encounter even in most typed languages as it requires purity.
But there are only very few type signatures for which this is true, even if you stick to totality.
That occurs quite often.
Are you referring to category laws?
That's because both addition and multiplication, for example, have the same type signature.
Prelude> :type (+)
(+) :: Num a => a -> a -> a
Prelude> :type (*)
(*) :: Num a => a -> a -> a
A better rephrasing might well be "If it compiles and you've used the right operations, which is made easier because most of the wrong operations will blow chunks all over the place, it works."Dependent typing anyone? (I think what you're looking for goes by the name "code extraction" in Coq, but I've never gotten into it as a programming environment.)
I would prefer is people just said "I program faster in Haskell"
You trolling every programming language discussion with fake names and sock puppets relating your fake made up experiences with functional programming. Do you have no dignity?