fork download
  1. mygcd :: Num a => (a, a) -> a
  2. mygcd (a, b) = a + b
  3.  
  4. main = do
  5. a <- 5
  6. b <- 8
  7. print $ mygcd (a, b)
Compilation error #stdin compilation error #stdout 0s 8388607KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:5:8: error:
    • No instance for (Num (IO a0)) arising from the literal ‘5’
    • In a stmt of a 'do' block: a <- 5
      In the expression:
        do { a <- 5;
             b <- 8;
             print $ mygcd (a, b) }
      In an equation for ‘main’:
          main
            = do { a <- 5;
                   b <- 8;
                   print $ mygcd (a, b) }

prog.hs:7:3: error:
    • Ambiguous type variable ‘a0’ arising from a use of ‘print’
      prevents the constraint ‘(Show a0)’ from being solved.
      Relevant bindings include
        b :: a0 (bound at prog.hs:6:3)
        a :: a0 (bound at prog.hs:5:3)
      Probable fix: use a type annotation to specify what ‘a0’ should be.
      These potential instances exist:
        instance Show Ordering -- Defined in ‘GHC.Show’
        instance Show Integer -- Defined in ‘GHC.Show’
        instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
        ...plus 22 others
        ...plus five instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In a stmt of a 'do' block: print $ mygcd (a, b)
      In the expression:
        do { a <- 5;
             b <- 8;
             print $ mygcd (a, b) }
      In an equation for ‘main’:
          main
            = do { a <- 5;
                   b <- 8;
                   print $ mygcd (a, b) }

prog.hs:7:11: error:
    • Ambiguous type variable ‘a0’ arising from a use of ‘mygcd’
      prevents the constraint ‘(Num a0)’ from being solved.
      Relevant bindings include
        b :: a0 (bound at prog.hs:6:3)
        a :: a0 (bound at prog.hs:5:3)
      Probable fix: use a type annotation to specify what ‘a0’ should be.
      These potential instances exist:
        instance Num Integer -- Defined in ‘GHC.Num’
        instance Num Double -- Defined in ‘GHC.Float’
        instance Num Float -- Defined in ‘GHC.Float’
        ...plus two others
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘($)’, namely ‘mygcd (a, b)’
      In a stmt of a 'do' block: print $ mygcd (a, b)
      In the expression:
        do { a <- 5;
             b <- 8;
             print $ mygcd (a, b) }
stdout

Standard output is empty