I am learning Haskell and after grasping some of the basics I decided to solve some easy problems in HackerRank. But I soon found myself stuck.
Problem 7 in Functional Problems is called "Array of N elements"
We are supposed to return any array of n elements for a given n. This would have fairly simple if n was an Int but it's read as IO Int
. And I haven't really grasped the concept of monads. I hoogled for functions with type signature IO Int -> Int
and found unsafePerform IO but it threw this:
Couldn't match expected type ‘t0 -> t’
with actual type ‘[Integer]’
I dont't quite understand what types t0 and t are.
Any help is appreciated.
Link: https://www.hackerrank.com/challenges/fp-array-of-n-elements/problem