Haskell : Use -XFlexibleContexts to permit this?

haskell

Solution

The context `Integral (Integral a, Integral b)` is probably not what you intended. It is more likely that you want `(Integral a, Integral b)` as in

calcstep ::Integral a => a -> a
calcstep  n = calcstep2 n 0

calcstep2 :: (Integral a, Integral b) => a -> b -> a
calcstep2 1 k = k
calcstep2 n k | odd n     = calcstep2 (n `div` 2) (k+1)
              | otherwise = calcstep2 (n * 3 + 1) (k+1)

Problem

My code as follows: ``` calcstep ::Integral a => a -> a calcstep n = calcstep2 n 0 calcstep2 :: Integral (Integral a, Integral b) => a -> b -> a calcstep2 1 k = k calcstep2 n k | odd n = calcstep2 (n/2) (k+1) | otherwise = calcstep2 (n*3+1) (k+1) ``` The error is as follows: Non type-variable argument in the constraint: Integral (Integral a, Integral b) (Use -XFlexibleContexts to permit this) In the type signature for `calcstep2': calcstep2 :: Integral (Integral a, Integral b) => a -> b -> a Failed, modules loaded: none. What does it mean? how can I fix it?

Original source