I'm starting my journey into Haskell and running into my first issue:
In my Haskell script:
myList = [1, 2, 3, 4, 5, 6, 7]
average ns = sum ns `div` length ns
when i'm in the ghci repl
, i get two different results:
- if i type
> average [1, 2, 3, 4]
i get the expected value of2
- but if i try to use myList and type
> average myList
, i get the error "Couldn't match type ‘Integer’ with ‘Int’"
I understand (at least i think i do) the concept of not having variables, so myList
is just a function that returns a "hardcoded" list everytime i call it.
How can i make this work, and why is it behaving like this?