Question: In Haskell, For replicate function, why I have to write (Ord a, Num a) for type, rather than (Num a) or (Ord a) ? ===============================

In Haskell,

For replicate function, why I have to write (Ord a, Num a) for type, rather than (Num a) or (Ord a)?

===============================

replicate' :: (Ord a, Num a) => a -> a -> [a]

replicate' n x

| n <= 0 = []

| otherwise = x : replicate' (n - 1) x

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!