Currently I am doing something like this in my code:
--Generate a list of n 'Foo's
generateFoos n = [createFoo (show i) | i <- [1..n]]
-- Create a Foo with a given name
createFoo :: String -> Foo
I was wandering if there is a another way of doing this than creating a range [1..n] all the time…
I would say don’t worry about it. “Creating the range
[1..n]” isn’t really going on here as a distinct step; that[1..n]desugars toenumFromTo 1 nand it’s constructed lazily like everything else anyway. There’s no hidden cost here one would need to eliminate.