I am a new programmer and I am taking a high school course called Introduction to Computational Thinking. We are learning Haskell with Code World, an online IDE. Our assignment is to draw some kites and make them move around a little bit. However, my teacher is not very helpful and the documentation is terrible. The compiler also gives error messages that don't make much sense to me. I know I need to either define two or more frames and flip between them in a loop, but I cannot figure out how to do this. There is also a function called animationOf, but I cannot figure out how to use it either. Even if I copy an example found on another website and try to paste it in Code World to test it, there are a ton of syntax errors.
For example, this will not compile even if I rename the variables to match my variables or try to write my own function like this:
trafficController :: Double -> Picture
trafficController t
| round (t/3) `mod` 2 == 0 = trafficLight True
| otherwise = trafficLight False
main :: IO ()
main = animationOf trafficController
That's from a Haskell website and it's not even the same syntax. I'm confused about what "version" of Haskell this even is that we're learning at school because it's seemingly different from every website I look at about Haskell. For example, we use program = drawingOf(whatever)
and don't use main
. It also tells me weird errors when I try to make my own function like "Double is not in scope", which makes no sense to me. If I have import Standard
I think basic types like Double should exist and be usable. Is there another library I have to import?
I tried defining two frames like this:
frame1 = [ kite(3,6,"red"), kite(-5,5,"purple"), kite(3,-5,"lightpink"),
stickfig, painted(solidRectangle(20,20),"sky blue")]
frame2 = [ kite(3.5,6.5,"red"), kite(-4.5,4.5,"purple"), kite(3.5,-5.5,"lightpink"),
stickfig, painted(solidRectangle(20,20),"sky blue")]
If I make an array of frames like combined[ frame1,frame2 ]
, I figured I can flip back and forth between those two to make a simple animation of the kites moving around. However, I can't even figure out how to make a loop to do this because the language feels so awkward to me and the documentation and examples are pretty useless. I've tried reading this documentation here and it doesn't help at all:
https://hackage.haskell.org/package/codeworld-api-0.3.1/docs/CodeWorld.html
I also have no idea how to use animationOf
and the documentation provides no answers and examples I find on Google don't work no matter how I try to modify them or writing my own versions following the syntax they show.
Also does anyone know what version of Haskell this is they're making us learn and why it's different from other versions I see. And are there any better resources out there for learning this stuff because our documentation and examples are terrible.