Many times in the course of my Haskell apprenticeship, I've had conversations of the following form:
Me: I want to do X in Haskell, but the obvious thing doesn't work. How do I do it?
Sensei (usually Duncan or
totherme): Oh no, you can't do that! If you could do that, then you could have a transperambic Papadopolous twisted asiatic sine-curve
(
Read more... )
Comments 36
Except, in all the above cases, it screws up. It turns out that you really need dynamic memory a lot of the time...
I think it's worth trying to imagine what it would mean to not screw up. Is there an underlying assumption here, that there exists a holy-grail language, which can precisely and elegantly describe everything in the universe? Is it possible that the languages mentioned work well enough in their own domains, only to require hacks and/or extensions when you try to use them for something unexpected ( ... )
Reply
Reply
Reply
I've been having a look, and can't find the specific problem that I'm thinking of - it was some feature that Mat wanted to add to Moblog (I think it was "Comments posted on (posts that you've commented on) since you last logged in") that we found we simply couldn't do in SQL. He had to set up a cron job to create an intermediate table. Possibly this was just a problem with MySQL (which at the time didn't support nested subqueries), but it was pretty lame.
Reply
Reply
Reply
main = print =<< randomRIO(1, 6)
or if you prefer: main = randomRIO(1, 6) >>= print - or even main = do x <- randomRIO(1, 6) ; print x
how is that any worse than main() { x := random(1,6) ; print(x); } ?
The thing is, I think imperative programmers are in monad land all the time. Functional programming offers a way of diving out ;)
Reply
Understanding your car (the engine, all the accompanying electrics and gubbins that keep it doing what you want, the transmission, etc) is Hard. But you can still drive.
Understanding Monads is Hard. You have be conversant in the most abstract, weird branch of mathematics I'm aware of. I think using them is deceptively easy - if you just concentrate on using them, and not understanding them. Accept that you can do sequencing (and things that rely on sequencing) inside the moand, but not outside. Trust it the same way you trust the compiler to write better assembly than you can, and concentrate on understanding more interesting things - like the meaning of your programme.
Reply
I think that when you say "haskellers prefer guarantees over expressiveness", it shows you're thinking roughly the right thing - haskellers certainly like guarantees.
OTOH, I'm not sure that this is the best way to say it to the world at large - because most haskellers would argue that through those guarantees you get more expressiveness out of your programming system than you would with a more naively expressive language. Haskellers don't want the guarantees because they like guarantees - they want them because they make writing cool code so much easier.
It's actually a really tricky thing to communicate, I think. At least - it is to someone who's already set themselves up to think in a very dynamic programming kind of way... It's really easy to teach haskell to non-coders ;)
Reply
Reply
Bob
Reply
Reply
I don't know what you need to use IPTs for, but as far as I've seen IPTs and DTs tend to be used to make type constraints tighter rather than making the type system more expressive. Can you explain the particular problem you need them for?
Bob
Reply
I want to have a go at it using the library greg_buchholz linked to now :-)
Reply
Reply
I'd wondered if it were possible to represent numbers as types, but decided it probably wasn't.
Reply
Leave a comment