kostaleonard / great-model-theory

A deep learning library for Scala.
MIT License
2 stars 0 forks source link

Remove use of Try/Success/Failure #41

Closed kostaleonard closed 1 year ago

kostaleonard commented 1 year ago

Try/Success/Failure provides functional error handling, but it is bleeding into all of the function signatures because anything that calls a Try/Success/Failure becomes a Try/Success/Failure. I think that a better design pattern is to just throw errors from incorrect arguments and shape mismatches. I also think that Try/Success/Failure is really more for network operations or system calls that can fail, not for users providing bad arguments to function calls.

kostaleonard commented 1 year ago

I've been researching and I really don't know what the best practice is. It seems like everyone in the Scala community is eager to say we should use Try/Success/Failure (or Option, which is less readable to me but gets the point across) because throwing errors is anti-functional, but does that mean we should handle errors when there's an array access or reshape operation that the user could mess up with an incorrect input? Scala docs don't suggest a reasonable threshold, and relatively little of the standard library uses Try or Option.

So, for now, I'm going to close this issue. I'll have to talk to Dr. Okasaki or some of the other language experts.

kostaleonard commented 1 year ago

Reopening for consideration. I want to see if I can get a second opinion.