fork(1) download
  1. sqrtEquation :: (Floating a, Floating b, Floating c) => a -> b -> c -> String
  2. sqrtEquation a b c
  3. | d < 0 = "No solutions"
  4. | d == 0 = (show x1)
  5. | d > 0 = (show x1) ++ " and " ++ (show x2)
  6. where d = (b*b - 4*a*c)
  7. x1 = ((-b + sqrt(d))/2*a)
  8. x2 = ((-b - sqrt(d))/2*a)
  9.  
  10.  
  11. main = do
  12. putStr "Input a:"
  13. a <- getLine
  14. putStr "Input b:"
  15. b <- getLine
  16. putStr "Input c:"
  17. c <- getLine
  18. let result = sqrtEquation (read a) (read b) $ read c
  19. putStrLn result
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:6:22:
    Could not deduce (a ~ b)
    from the context (Floating a, Floating b, Floating c)
      bound by the type signature for
                 sqrtEquation :: (Floating a, Floating b, Floating c) =>
                                 a -> b -> c -> String
      at prog.hs:1:17-77
      `a' is a rigid type variable bound by
          the type signature for
            sqrtEquation :: (Floating a, Floating b, Floating c) =>
                            a -> b -> c -> String
          at prog.hs:1:17
      `b' is a rigid type variable bound by
          the type signature for
            sqrtEquation :: (Floating a, Floating b, Floating c) =>
                            a -> b -> c -> String
          at prog.hs:1:17
    Relevant bindings include
      d :: b (bound at prog.hs:6:9)
      b :: b (bound at prog.hs:2:16)
      a :: a (bound at prog.hs:2:14)
      sqrtEquation :: a -> b -> c -> String (bound at prog.hs:2:1)
    In the second argument of `(*)', namely `a'
    In the first argument of `(*)', namely `4 * a'

prog.hs:6:24:
    Could not deduce (c ~ b)
    from the context (Floating a, Floating b, Floating c)
      bound by the type signature for
                 sqrtEquation :: (Floating a, Floating b, Floating c) =>
                                 a -> b -> c -> String
      at prog.hs:1:17-77
      `c' is a rigid type variable bound by
          the type signature for
            sqrtEquation :: (Floating a, Floating b, Floating c) =>
                            a -> b -> c -> String
          at prog.hs:1:17
      `b' is a rigid type variable bound by
          the type signature for
            sqrtEquation :: (Floating a, Floating b, Floating c) =>
                            a -> b -> c -> String
          at prog.hs:1:17
    Relevant bindings include
      d :: b (bound at prog.hs:6:9)
      c :: c (bound at prog.hs:2:18)
      b :: b (bound at prog.hs:2:16)
      sqrtEquation :: a -> b -> c -> String (bound at prog.hs:2:1)
    In the second argument of `(*)', namely `c'
    In the second argument of `(-)', namely `4 * a * c'
stdout
Standard output is empty