Skip to content

Commit 1919ece

Browse files
authored
Merge pull request #27 from herrzinter/showable-ratios
Showable ratios
2 parents bb3d435 + febfe43 commit 1919ece

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Data/Ratio.purs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ module Data.Ratio
88
import Prelude ( class CommutativeRing, class Eq, class EuclideanRing
99
, class Field, class Ring, class Semiring
1010
, one, zero, (*), (+), (-)
11+
, class Show, show, (<>)
1112
)
1213
import Prelude ( gcd ) as Prelude
1314

1415
data Ratio a = Ratio a a
1516

17+
instance showRatio :: Show a => Show (Ratio a) where
18+
show (Ratio a b) = "(Ratio " <> show a <> " " <> show b <> ")"
19+
1620
instance semiringRatio :: Semiring a => Semiring (Ratio a) where
1721
one = Ratio one one
1822
mul (Ratio a b) (Ratio c d) = Ratio (a * c) (b * d)

0 commit comments

Comments
 (0)