So, das ist jetzt zwar unglaublich billig, aber …
Code:
#!/usr/bin/runhaskell
main :: IO ()
main = do
let 2 + 2 = 5 in
putStrLn $ "2 + 2 = " ++ show (2 + 2)
Ein
haskell-compiler foo.hs && ./foo tut freilich auch.
Auch lustig, von shiona_ aus #haskell:
Code:
data MyNum = MyNum Integer
instance Num MyNum where
(MyNum 2) + (MyNum 2) = MyNum (5)
(MyNum x) + (MyNum y) = MyNum (x + y)
(MyNum x) - (MyNum y) = MyNum (x - y)
(MyNum x) * (MyNum y) = MyNum (x * y)
abs (MyNum x) = MyNum (abs x)
fromInteger = MyNum
instance Show MyNum where
show (MyNum x) = show x
main = do
let foo = 2 + 2 :: MyNum
print foo