Introduce the Data.Complex and Data.Ratio
Today's Haskell: introduce the Data.Complex and Data.Ratio
import Data.Complex
import Data.Ratio
num :: Floating a => a -> Complex a
num x = (exp x) :+ pi
num' :: (Integral a, RealFrac b, Floating b) => b -> Ratio a
num' x = floor (exp x) % ceiling pi
main :: IO()
main = do
print $ num $ x
print $ num' $ x
where x = 1
$ ghc -V
The Glorious Glasgow Haskell Compilation System, version 8.10.4
$ ghc main.hs -o app.out
$ ./app.out
2.718281828459045 :+ 3.141592653589793
1 % 2