fork download
  1. data Vector = V { x :: Int, y :: Int } deriving Show
  2.  
  3. instance Num Vector where
  4. (V x0 y0) + (V x1 y1) = V (x0+x1) (y0+y1)
  5.  
  6. main = do print $ 1 + 2
  7. print $ (V 1 3) + (V 6 9)
Success #stdin #stdout 0s 6232KB
stdin
Standard input is empty
stdout
3
V {x = 7, y = 12}