fork download
  1. {-# LANGUAGE RankNTypes #-}
  2.  
  3. main = let f:: (Num a => forall a. a -> a) -> (Int, Float)
  4. f g = (g 1, g 2.3)
  5. in print $ f ((+ 1) :: Num a => a -> 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:
    No instance for (Num a) arising from a use of `g'
    Possible fix:
      add (Num a) to the context of
        the type signature for
          f :: (Num a => forall a1. a1 -> a1) -> (Int, Float)
    In the expression: g 1
    In the expression: (g 1, g 2.3)
    In an equation for `f': f g = (g 1, g 2.3)

prog.hs:5:23:
    Could not deduce (Num a) arising from an expression type signature
    from the context (Num a_l)
      bound by a type expected by the context: Num a_l => a -> a
      at prog.hs:5:20-47
    Possible fix:
      add (Num a) to the context of
        a type expected by the context: Num a_l => a -> a
    In the first argument of `f', namely `((+ 1) :: Num a => a -> a)'
    In the second argument of `($)', namely
      `f ((+ 1) :: Num a => a -> a)'
    In the expression: print $ f ((+ 1) :: Num a => a -> a)
stdout
Standard output is empty