Created
May 16, 2016 08:51
-
-
Save sharkdp/cef1f5e2eddd1125176d08daa03ef45a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Prelude | |
import Control.Monad.Eff.Console | |
import Data.Int as I | |
import Data.Complex as C | |
import Math as M | |
class Ring r <= Absolute r where | |
abs :: r -> Number | |
instance absoluteNumber :: Absolute Number where | |
abs = M.abs | |
instance absoluteInt :: Absolute Int where | |
abs = M.abs <<< I.toNumber | |
instance absoluteComplex :: Absolute C.Complex where | |
abs = C.magnitude | |
main = do | |
print $ abs (-2.3) | |
print $ abs (-3) | |
print $ abs (C.outCartesian (C.Cartesian 3.0 4.0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment