Code:
product :: (Eq p, Num p) => p -> p
product 1 = 1
product n = n * product (n-1)
Usage:
main = print (product(8))
Error:
GHCi, version 8.10.6: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/runner/University-Labs/.ghci
[1 of 1] Compiling Main ( Main.hs, interpreted )
Main.hs:3:17: error:
Ambiguous occurrence ‘product’
It could refer to
either ‘Prelude.product’,
imported from ‘Prelude’ at Main.hs:1:1
(and originally defined in ‘Data.Foldable’)
or ‘Main.product’, defined at Main.hs:2:1
|
3 | product n = n * product (n-1)
| ^^^^^^^
Main.hs:5:15: error:
Ambiguous occurrence ‘product’
It could refer to
either ‘Prelude.product’,
imported from ‘Prelude’ at Main.hs:1:1
(and originally defined in ‘Data.Foldable’)
or ‘Main.product’, defined at Main.hs:2:1
|
5 | main = print (product(8))
| ^^^^^^^
Failed, no modules loaded.
<interactive>:1:1: error:
• Variable not in scope: main
• Perhaps you meant ‘min’ (imported from Prelude)
^