## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# How to do it...

1. Open Quadratic.hs and add a module definition to it:
`       module Quadratic where`
1. Import the standard module Data.Complex to help us represent a complex solution to the quadratic equation.
2. Define the data type to represent the quadratic equation:
`      data Quadratic = Quadratic { a :: Double, b :: Double,         c :: Double }         deriving Show`

This represents the quadratic equation of the form a∗x2+b∗x+c=0a∗x2+b∗x+c=0.  a, b, and c represent the corresponding constants in the equation.

1. Define the data type for representing the root:
`      type RootT = Complex Double`

This represents that the complex data type parameterized by Double. RootT is synonymous to type Complex Double (similar to typedef in C/C++).

1. A quadratic equation has two roots, ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required