[Haskell-cafe] External Interfaces

Victor Miller victorsmiller at gmail.com
Sat Mar 3 19:24:10 CET 2012


I'd like to write reasonable Haskell interfaces to a few external
libraries.  To be specific -- all of them do limited calculations (no
I/O) but each has an internal state.  I know that I can have results
dump everything into the IO monad, but I'd like to avoid the "sin bin"
(I think it was Phil Wadler who called it that).  To be specific, I
have in mind the library pari ( http://en.wikipedia.org/wiki/PARI/GP )
which does symbolic algebra calculations.  The way that the pari state
works is that state of works is that we can add definitions of new
quantities, and bind them to a calculated value.  As part of the state
there might be certain cached calculations.  If I avoid deleting bound
objects, it seems to me that it would be perfectly valid to make the
interface into a monad have a complicated state which is being managed
by the pari library.  As long as any queries from pari give the same
value (which should be the case if I never delete anything) then it
should be valid without dumping things into the IO monad.  Does anyone
see anything wrong with my reasoning?

Victor



More information about the Haskell-Cafe mailing list