[Haskell-beginners] function application

mike h mike_k_houghton at yahoo.co.uk
Sun Apr 10 16:16:24 UTC 2016


Hi,

I’m looking at

mc :: (Integral a) => a -> a
mc x
  | x > 100 = x - 10 
  | otherwise = mc ( mc  ( x + 11 ) )

the  mc ( mc  ( x + 11 ) ) can also be written  as 

mc . mc  $ x + 11 

and I expected it could also be written as 

mc . mc ( x + 11 )

but the compiler error starts off with

Couldn't match expected type ‘a’ with actual type ‘a0 -> c0’

so that is telling me, isn’t it (?) ,  that using parens is making the argument to the second mc into a function  ‘a0 -> c0’

So is 
mc . mc  $ x + 11 

the only correct way to write this particular function in  ‘.’ style ?

Many Thanks

Mike





More information about the Beginners mailing list