5 ms·
That's not quite true, it must either be correct or bottom. I can write: id :: a -> a id = id
by DanWaterworth 14y ago
That's not quite true, it must either be correct or bottom.
I can write:
id :: a -> a
id = id
- sanxiyn 14y agoThis is why Haskell is evil and you should use ML.
- eadvgf 14y agoYou can still write x=_|_ in ML, you just have to be subtler about it.
- batterseapower 14y agoid x = id x
- kfl 14y agoYes in ML you'd have to eta-expand first: val id : 'a -> 'a fun id x = id x
- tikhonj 14y agoThis is why Turing-complete languages are evil and you should use Agda.
- GregBuchholz 14y agoFor certain definitions of correct... id :: a -> a id a = case (a,unsafePerformIO (print "rm -rf *")) of (x,()) -> a
- applicative 14y agoNote the "Safety Inferred" seal of approval on the upper right hand corner of the hackage package http://hackage.haskell.org/packages/archive/lens-family-core/0.0.0/doc/html/Lens-Family.html http://hackage.haskell.org/packages/archive/lens-family-core... This means it survives a recursive check of dependencies that precludes that kind of nonsense.
- DanWaterworth 14y agoI hadn't thought of that. Types serve as a good safety net, but they're not foolproof. Expecting something like that to be correct because it passed through the type checker is like expecting to be served at a restaurant dressed in a gorilla suit because you got through the door.
- GregBuchholz 14y agoAnd of course it is fun to think about total functions that are "effectively" bottom... id :: a -> a id a = case (a,ack 4 3) of (x,0) -> x (x,_) -> x where ack 0 n = n+1 ack m 0 = ack (m-1) 1 ack m n = ack (m-1) (ack m (n-1))
- heretohelp 14y agoHi. I make a living writing code. Also, I'm bad at math other than bit arithmetic and calculating tips. (Edit: I guess I sort of understand sets and basic set operations) What in the hell are you two talking about and why shouldn't I take this as a sign that I should avoid Haskell at all costs?
- DanWaterworth 14y agoYou can prove properties in Haskell using the type system, (provided that you can show that the expression you are proving properties about actually terminates). I was merely pointed out that last part in the most succinct way I knew how. You should definitely not avoid Haskell at all costs. I would characteristic programming as the process of constructing systems and managing complexity. If you have a greater exposure to languages and paradigms then you have more tools at you disposal for doing your job. A programmer may be able to get by without knowing anything about Haskell or functional programming in general, but that's only because they don't realize when they are kludging something that is so simple if only it was thought about differently.
- heretohelp 14y agoI'm a grumpy old clisper. I know well the benefits of functional programming. (And Perlis languages in general. If you don't know the c2 page for this, you should feel deep shame.) Thing is, my fellow lispers, and our scheming siblings too, spent most our time talking about programming or actual code. The former being the means or mode to produce the latter. Why don't Haskellers ever seem to be talking about programming or actual code when I encounter them in the wild? Haskell seems to be some mad science project that came about after some grad students happened across an ML manual and a bottle of scotch. (At least you guys didn't make that 31-bit integer mistake. Oof, tagged pointers.) The emphasis on the type system seems to be a bit revisionist to me. The original (pre-Haskell '98) emphasis was on the laziness really. That turned out to be a huge mistake outside of some cute demonstrations for the purpose of understanding the runtime behavior of your code, so you're choosing to ignore this monstrous mistake and instead promulgate this type safety nonsense as if static analysis has gone anywhere in the last few decades. So back to my original questions, why don't I ever seem to find you people talking about actual code? When I encounter fellow Python programmers, they're usually talking about cool libraries, solving interesting problems, neat tools they've discovered or made, best practices, etc. With Haskell it's more like I've bumped into a rather unpleasant evangelical minister or Amway salesman bred with Doc Brown from Back to the Future. It's like the Haskell community has two modes of operation: proselytization and mathematical gibberish.