4 ms·
At first glance it looks like a fun esoteric language, like Shakespeare [1]. Looking deeper, this language is more amazing then it leads on to be. But for a l
by munro 12y ago
At first glance it looks like a fun esoteric language, like Shakespeare [1]. Looking deeper, this language is more amazing then it leads on to be.
But for a little story time: I've started my first major project in Haskell while sick the past week, and it had me asking lots of questions:
Why do I have to add so many parentheses to get it to compile? Why can't I just pass monads into my functions? Why is every function not polymorphic? Why do I get so many pattern matching errors even with -Wall? :( The last one stings the most, believing my program would never crash. But every function being polymorphic really got me thinking, since instancing type classes with Monads was my first instinct. It felt so natural.
instance (Monad m, Num a) => Num (m a) where
(+) = liftM2 (+) -- ((return 123) + (return 321)) -- yipee!
...
I realize that type classes are global, and could have cascading problems. Even still, this made me want to prototype a language where all functions are polymorphic, but after looking over Avail, it seems to answer all my questions. It feels like a Lispy haskell; static type checking, with context sensitive polymorphism.
With this kind of polymorphism, one of my first thoughts was what the code compiles in an unintended way due to the way I specified. The metaphor I thought of to reason about this was: a copilot in the car tells you "Turn right here". Are they saying to turn right at the next intersection, or that this is the intersection that you should be turning at? This example shows succinctly shows that it's a problem with the language being define (i.e. the code), that "right" is overloaded to mean a direction, or immediately.
Anyways, I would love for anyone to weigh in, since I've been thinking about this a lot recently!
[1] http://en.wikipedia.org/wiki/Shakespeare_(programming_language) http://en.wikipedia.org/wiki/Shakespeare_(programming_langua...
- ky3 12y ago> Why do I get so many pattern matching errors even with -Wall? :( The last one stings the most, believing my program would never crash. I hope your programs never crash, and in the meantime could you explain what > Why do I get so many pattern matching errors even with -Wall? means? Perhaps you meant: > Why do I get so many pattern matching errors because of -Wall? These are incomplete-pattern-match warnings, yes?