4 ms·
Interestingly, if you rewrite the function with a more general type such as checkCapacity' :: forall f. Functor f => Int -> (ZonedTime -> f Int) -> Reserva
by wz1000 9y ago
Interestingly, if you rewrite the function with a more general type such as
checkCapacity' :: forall f. Functor f => Int -> (ZonedTime -> f Int) -> Reservation -> f (Either Error Reservation)
you can guarantee that any effects in the final result only come from the function you supplied to it, i.e. checkCapacity' cannot add any effects of its own(Also, it can only "run" the function exactly once).
The type of the arguments of checkCapacity' are also a strict generalisation of the arguments to
checkCapacity :: Int -> (ZonedTime -> IO Int) -> Reservation -> Either Error Reservation
meaning that any valid arguments to checkCapacity are valid for checkCapacity' as well.
- tome 9y agoI think you must mean checkCapacity :: Int -> (ZonedTime -> IO Int) -> Reservation -> IO (Either Error Reservation)