Open MartinSStewart opened 4 years ago
As I'm using my own implementation of this, I'm finding that it might be more useful in this form
mapBoth : (Result e a -> Script e1 a1) -> Script e a -> Script e1 a1
mapBoth map =
Script.attempt >> Script.thenWith map
Edit: the name mapBoth might not make so much sense now though.
Yeah, I think I would expect a mapBoth
to have a signature like
mapBoth : (x -> y) -> (a -> b) -> Script x a -> Script y b
to match Result.Extra.mapBoth. Maybe mapResult
and thenWithResult
instead?
mapResult : (Result x a -> Result y b) -> Script x a -> Script y b
thenWithResult: (Result x a -> Script y b) -> Script x a -> Script y b
It would be nice to have a function like this as it's not entirely obvious how to implement it with the existing functions and it's useful to have this level of flexibility sometimes.