It is indeed a very difficult task to test children's programs in the Haskell REPL (GHCi).
Using let not very obvious (especially since it is not required in a separate "script / program").
And sometimes we DO NOT want to create a full-fledged file, but instead experiment with a small function with different βcasesβ.
Another useful approach is to use delimiters :{ and :} to determine the extent of our function.
Let's say we want to try a simple recursive function sum , which can contain a list of numbers. We would then say the following:
Ξ» > :{ Prelude| sum [] = 0 Prelude| sum (x:xs) = x + sum xs Prelude| :} sum :: Num t => [t] -> t Prelude Ξ» > sum [1..10] 55 it :: (Enum t, Num t) => t
Pay attention to how nice it is to see the scale of our function now!
Hope this helps. Hooray!
fritz
source share