fork download
  1. {-# LANGUAGE FlexibleInstances #-}
  2.  
  3. class Monoid a where
  4. mempty :: a
  5. mappend :: a -> a -> a
  6.  
  7. instance Monoid (a -> b) where
  8. mempty f = f
  9. mappend f g = g . f
  10.  
  11. main = return ()
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:8:19:
    Couldn't match expected type `b' with actual type `a'
      `b' is a rigid type variable bound by
          the instance declaration at prog.hs:7:10
      `a' is a rigid type variable bound by
          the instance declaration at prog.hs:7:10
    In the expression: f
    In an equation for `mempty': mempty f = f
    In the instance declaration for `Monoid (a -> b)'

prog.hs:9:23:
    Couldn't match type `b' with `a'
      `b' is a rigid type variable bound by
          the instance declaration at prog.hs:7:10
      `a' is a rigid type variable bound by
          the instance declaration at prog.hs:7:10
    Expected type: a -> a
      Actual type: a -> b
    In the second argument of `(.)', namely `f'
    In the expression: g . f
    In an equation for `mappend': mappend f g = g . f
stdout
Standard output is empty