I am implementing an algorithm using Data.Ratio (convergents of continued fractions).
However, I encounter two obstacles:
- The algorithm starts with the fraction
1%0- but this throws a zero denominator exception. - I would like to pattern match the constructor
a :% b
I was exploring on hackage. An in particular the source seems to be using exactly these features (e.g. defining infinity = 1 :% 0, or pattern matching for numerator).
As beginner, I am also confused where it is determined that (%), numerator and such are exposed to me, but not infinity and (:%).
I have already made a dirty workaround using a tuple of integers, but it seems silly to reinvent the wheel about something so trivial. Also would be nice to learn how read the source which functions are exposed.