[Haskell-cafe] Another question about unsafePerformIO

Matthias Görgens matthias.goergens at googlemail.com
Thu Jun 25 09:38:41 EDT 2009

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?

More information about the Haskell-Cafe mailing list