{-| Module : Fractions Description : Use Haskell for fraction calculations Copyright : © Frank Jung, 2020 License : GPL-3 -} module Fractions (sumOfFractions) where import Data.Ratio (Ratio, (%)) -- | Add two fractions. -- -- To try this in GHCi: -- > import Data.Ratio -- > let result = (28 % 50) + (26 % 50) -- > result -- 27 % 25 -- -- Or load this file and run: -- > sumOfFractions -- 27 % 25 sumOfFractions :: Ratio Integer sumOfFractions :: Ratio Integer sumOfFractions = Integer 28 Integer -> Integer -> Ratio Integer forall a. Integral a => a -> a -> Ratio a % Integer 50 Ratio Integer -> Ratio Integer -> Ratio Integer forall a. Num a => a -> a -> a + Integer 26 Integer -> Integer -> Ratio Integer forall a. Integral a => a -> a -> Ratio a % Integer 50