Jamie Ballingall
Jamie Ballingall

Reputation: 289

MonadIO to Maybe

I've been using HMatrix for linear algebra and it's linearSolve function has the straightforward (albeit terse) type:

linearSolve :: Field t => Matrix t -> Matrix t -> Maybe (Matrix t)

I'd like to try out the sparse-linear-algebra library and it's <\> function (not the <\> function in HMatrix), which has type:

(<\>) :: (MonadIO m, MonadThrow m) => MatrixType v -> v -> m v

While I'd like to use the additional information that this provides, I'd like to start with just a drop-in replacement of type:

MatrixType v -> v -> Maybe v

so that I don't have rewrite my code all the way back up to main. How can I do that?

I'm fairly new to Haskell and still at the "Oh! I understand monads now. No! Wait! It's gone again" phase.

Thanks

Upvotes: 3

Views: 239

Answers (1)

Jamie Ballingall
Jamie Ballingall

Reputation: 289

Based on the comments it seems like:

  1. Once you're in Monad IO there is no escape. As such, the answer to the original newbie Haskeller question is "you can't"
  2. The library author, @ocramz, had existing plans to use MonadLogger and we may see something as part of an upcoming redesign

Upvotes: 1

Related Questions