
25 Jun
2009
25 Jun
'09
1:38 p.m.
I have a program that optimizes train schedules. It employs an external solver for Integer Linear Programs. The solve function has the following type:
solve :: Constraints -> IO (Maybe Solution)
And this works. However, my external solver also behaves like a pure function from input to output. I wonder whether this guarantee should be reflected in the type system. I'd also appreciate if the compiler would be able to eliminate some calls to the solver.
solvePure :: Constraints -> Maybe Solution solvePure = unsafePerformIO . solve
Is this a good idea?