how to put together lots of little bits of infomation
Haskell Notation and Symbols: What Are They? What Do They Even Do?? Let’s Find Out! (feat. alliteration)
Super Special Assorted Symbols
A lot of computer science, especially the programming part, uses a lot of symbols. For example:
func :: Type -> Type -> Type
func x y = _________________
With so many different symbols and notations sitting around, let’s consolidate our knowledge. Try make a mind map using examples and the symbols that compose them.
So This Symbol Signifies
Now we have uncovered what symbols can be known, let’s note what they mean! Manafacture a menu of meanings for your mindmap’s symbols. (Define the symbols found in your mind map… we aren’t good at alliteration).
Devious Doctors
Look at these statements; currently they are totally detached. Your task, as type doctor, is to connect each sentence to a type.
Note:
data Pal = Edmund | Jay | Cameron | Cassy | Razi | Yichen
- Identify the problems with the following declaration
maybe Integer = Just Int | Nothing
- What is the type of these statements?
(4 + 6) (2*) 'p' 'p' : "als" Edmund
- What is the differences between these symbols?
:: vs : ++ vs + type vs data
With your great skill, you have graduated from type doctor to function doctor! Take this function and disect it:
- Circle the function name
- underline the type signature
- Circle the function body
- underline the function parameters
- Discuss in your groups what all these terms mean
- what would be a better name for this function
simple_function :: Float -> Float -> Float simple_function x y = sqrt ((x - 0.0)**2 + (y - 0.0)**2)
Stealthy and Sneaky Functions
These functions are stealthy and sneky; parts of these are out of sight! Fill in the blanks:
it_double :: ___ -> ___
it_double ___ = ___ + ___
_______ :: ____ -> ____
_______ ___ = "hello there, " ++ name
Now that you have found these fun and fruity functions, have a go writing the following functions:
- square an Integer
- return True if two Bools are equal
- find the distance between two points in 2D space