fork download
  1. {-# LANGUAGE RankNTypes #-}
  2.  
  3. f :: (forall a. a -> b) -> (a, a2) -> (b, b2)
  4. f g (x, y) = (g x, g y)
  5.  
  6. main = print $ f show (1, 'a')
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:4:20:
    Couldn't match expected type `b2' with actual type `b'
      `b2' is a rigid type variable bound by
           the type signature for
             f :: (forall a1. a1 -> b) -> (a, a2) -> (b, b2)
           at prog.hs:3:6
      `b' is a rigid type variable bound by
          the type signature for
            f :: (forall a1. a1 -> b) -> (a, a2) -> (b, b2)
          at prog.hs:3:6
    In the return type of a call of `g'
    In the expression: g y
    In the expression: (g x, g y)

prog.hs:6:9:
    No instance for (Show b20) arising from a use of `print'
    The type variable `b20' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    Note: there are several potential instances:
      instance Show Double -- Defined in `GHC.Float'
      instance Show Float -- Defined in `GHC.Float'
      instance (Integral a, Show a) => Show (GHC.Real.Ratio a)
        -- Defined in `GHC.Real'
      ...plus 23 others
    In the expression: print
    In the expression: print $ f show (1, 'a')
    In an equation for `main': main = print $ f show (1, 'a')

prog.hs:6:19:
    No instance for (Show a) arising from a use of `show'
    Possible fix:
      add (Show a) to the context of
        a type expected by the context: a -> [Char]
    In the first argument of `f', namely `show'
    In the second argument of `($)', namely `f show (1, 'a')'
    In the expression: print $ f show (1, 'a')
stdout
Standard output is empty