Skip to content

Instantly share code, notes, and snippets.

@rahult
Last active August 11, 2017 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahult/dc4be01d98a1026f4c5e94e8f2c84cc4 to your computer and use it in GitHub Desktop.
Save rahult/dc4be01d98a1026f4c5e94e8f2c84cc4 to your computer and use it in GitHub Desktop.
Complex Number
module Main where
import Prelude
newtype Complex = Complex {
real :: Number,
imaginary :: Number
}
instance showComplex :: Show Complex where
show (Complex { real: r, imaginary: i }) = show r <> " + " <> show i <> "i"
instance eqComplex :: Eq Complex where
(==) (Complex { real: a1, imaginary: b1 }) (Complex { real: a2, imaginary: b2 }) = a1 == a2 && b1 == b2
@rahult
Copy link
Author

rahult commented Aug 11, 2017

Keep getting this error when I try to compile this file

Error found:
at src/Main.purs line 14, column 3 - line 14, column 3

  Unable to parse module:
  unexpected (
  expecting indentation at column 1 or end of input

@rahult
Copy link
Author

rahult commented Aug 11, 2017

Fixed by changing (==) to eq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment