Skip to content

Instantly share code, notes, and snippets.

@rahult
Last active August 11, 2017 10:54
Show Gist options
  • Save rahult/dc4be01d98a1026f4c5e94e8f2c84cc4 to your computer and use it in GitHub Desktop.
Save rahult/dc4be01d98a1026f4c5e94e8f2c84cc4 to your computer and use it in GitHub Desktop.

Revisions

  1. rahult renamed this gist Aug 11, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. rahult created this gist Aug 11, 2017.
    14 changes: 14 additions & 0 deletions Complex.purs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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