Friday, February 06, 2009

Regression

They say that as you get older you regress back towards childhood. So I present you with today's Haskell program (the idea shamelessly stolen from JoshTriplett from #haskell on IRC):
import BASIC

main = runBASIC $ do

    10 LET X =: 1
    20 PRINT "Hello BASIC world!"
    30 LET X =: X + 1
    40 IF X <> 11 THEN 20
    50 END
Yes, it runs. (I'm sorry about the =: instead of =, but some things are just too wired into Haskell to change.)

Labels: , ,

13 Comments:

Blogger Qrilka said...

And where can we find BASIC module?

Friday, February 6, 2009 at 11:39:00 AM GMT  
Blogger Arnar Birgisson said...

Ooo, I like this.

Friday, February 6, 2009 at 2:48:00 PM GMT  
Blogger Gleb said...

Nice. I guess this is based on PrintfType-like type class trickery and doesn't reject invalid basic programs until runtime, right?

Friday, February 6, 2009 at 3:37:00 PM GMT  
Blogger augustss said...

It can go wrong in many ways at runtime, just like real BASIC. :)

Friday, February 6, 2009 at 3:39:00 PM GMT  
Blogger Matt Hellige said...

Does it run if we reorder the statements? Or are the line numbers just for show? In other words, does this work?

50 END
20 PRINT "Hello BASIC world!"
30 LET X =: X + 1
40 IF X <> 11 THEN 20
10 LET X =: 1

Friday, February 6, 2009 at 4:27:00 PM GMT  
Blogger augustss said...

You can reorder the statements if you like.

Friday, February 6, 2009 at 4:59:00 PM GMT  
Blogger Quiz said...

I take it there is a limit on the available variable names? Not that this is ahistorical: Commodore BASIC ignored all but the first two letters, for example; but allowing arbitrary names would be a challenge.

Friday, February 6, 2009 at 9:05:00 PM GMT  
Blogger augustss said...

Quiz: Dartmouth BASIC has a limit of 286 variables.

Friday, February 6, 2009 at 9:46:00 PM GMT  
Blogger Magnus Carlsson said...

Lennart - this made my day. I can smell the food in my mother's kitchen.

Saturday, February 7, 2009 at 4:27:00 AM GMT  
Blogger PO8 said...

Hey, this was my idea! And Josh also has a working implementation!

It's cool that you went ahead and did an implementation as well, and cool that you gave Josh credit. However, it would also have been nice to give us a little time to get ours out first. We had big 1 April plans for it.

I hereby sentence you to write a few thousand lines of HBASIC. :-)

Sunday, February 8, 2009 at 12:26:00 AM GMT  
Blogger augustss said...

PO8: I'm sorry, I didn't know it was your idea. Nor that you had plans.

My apologies.

Sunday, February 8, 2009 at 3:24:00 AM GMT  
Blogger PO8 said...

It's all good fun. I mostly just wanted to clarify the situation. Josh and I will keep poking at it also---we're already making our next plans.

It looks like you have the HBASIC language pretty clean at this point with your implementation. Will you post the source code soon?

Sunday, February 8, 2009 at 6:49:00 AM GMT  
Blogger blog for steveLi said...

Nice. I guess this is based on PrintfType-like type class trickery and doesn't reject invalid basic programs until runtime, right?cheap electronics

Friday, February 18, 2011 at 2:50:00 PM GMT  

Post a Comment

<< Home