Skip to content
August 23, 2011 / cdsmith

Haskell For Kids: My Project!

Oops!  I almost forgot to do my own homework from my Haskell for Kids class!

Here’s the program I wrote (intentionally using only the features we’d already talked about in class.)

import Graphics.Gloss

picture = pictures [
    color lightGray (rectangleSolid 500 500),
    translate  0 (-75) (color darkGray mouse),
    translate 90 (150) thoughtBubble
    ]

darkGray = light black
lightGray = dark white

thoughtBubble = pictures [
                            (scale 100 50 filledCircle),
    translate ( -85) ( -15) (scale 0.4 0.4 (text "I wonder...")),
    translate ( -85) ( -65) (scale 20 20 filledCircle),
    translate (-120) (-110) (scale 15 15 filledCircle)
    ]

filledCircle = pictures [
    color white (circleSolid 1),
    color black (circle 1)
    ]

mouse = pictures [
    scale 2   1 (circleSolid 50),
    translate (-100) ( 40) mouseHead,
    translate ( 120) (-20) mouseTail,
    translate ( -40) (-55) mouseLegs,
    translate (  20) (-55) mouseLegs
    ]

mouseHead = pictures [
    translate 20 35 (color rose (circleSolid 20)),
    translate 20 35 (thickCircle 5 40),
    rotate (-10) (scale 1.5 1 (circleSolid 40))
    ]

mouseTail = (rotate (-15) (rectangleSolid 100 5))

mouseLegs = pictures [
    rectangleSolid 5 35,
    translate 20 0 (rotate 10 (rectangleSolid 5 35))
    ]

And the result:

About these ads

5 Comments

Leave a Comment
  1. suesun / Aug 23 2011 9:58 pm

    cute!

  2. Steve Powell / Aug 25 2011 10:35 am

    This is such a nice class that I’m going to follow it all the way! Everyone seems to be having so much fun! Well done.

    After about forty years of programming, I thought I’d discovered the really important lessons in this field. You have covered nearly all of them in just two weeks!

    I can’t wait for the rest.

  3. Edvard Majakari / Mar 21 2012 7:41 am

    Your idea was nothing short of awesome. I tried to do something very similar here, but unfortunately in the school I tried it interest was not sufficient enough. Have to try other schools and/or try again in Autumn.

    But I wanted to say that you acted as a catalyst for me to start making it happen! I won’t rest until I get to do it. I think Haskell is an excellent choice – language itself isn’t that hard, and kids don’t need to unlearn things (OOP/crappy procedural style etc).

    • cdsmith / Mar 21 2012 8:18 am

      Edvard, you might be interested to know that I’m working on writing up my experience this year as a more complete-sounding curriculum guide, with data on alignment with academic standards (if you’re in the U.S.) and specific recommended worksheets, activities, and such. It’s turning into quite the project (the teacher’s guide is at about 150 pages and I’m somewhere around 40% done with the first draft), so it might be another couple months before I have anything to share. But I’d be happy to share it with you when it’s done, if that would help in the selling or the teaching.

Trackbacks

  1. Haskell for Kids: Week 2! « Sententia cdsmithus

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 73 other followers

%d bloggers like this: