
1 Jun
2010
1 Jun
'10
10:46 a.m.
On Tue, Jun 1, 2010 at 10:30 AM, Gery Debongnie
3. Perform a reading of the font metrics file in the main program, put the results into some FontMetrics object, and give that to stringWidth :: FontMetrics -> Font -> String -> Double. Pros : allow me to avoid problems of solution 1 and 2, cons : it doesn't sound right for the main program to have to do this, it should be confined into a Font module.
Ultimately all your IO is driven from main, so don't be afraid to add more IO dependencies to it. You can let IO "infect" a module for dealing with font files (e.g. a FontMetrics module with a function getMetrics :: [String] -> Map String Double), then drive that module from main and feed its results into your pure code. Anthony