I see this as the general form of a factorial function in Haskell:
factorial :: (Integral a) => a -> a
factorial n = product [1..n]
I understand this is the most elegant way, but when I write my own recursive function to do it, it's significantly slower:
factorial :: (Integral a) => a -> a
factorial 1 = 1
factorial n = n * factorial (n - 1)
Doesn't the first solution have to do pretty much everything that the first one does, internally? How is it so much faster? Is it possible to write something as fast as the first solution without using the fancy list notation or the product function?