Documentation ¶
Index ¶
- type Exception
- type LogLevel
- type R
- func (r R[T]) Bind(f func(T) (T, error)) R[T]
- func (r R[T]) Catch(f func(T) T) (r2 R[T])
- func (r R[T]) Handle(onSuccess func(T), onError func(error)) R[T]
- func (r R[T]) Map(f func(T) T) R[T]
- func (r R[T]) Recover(f func(T, error) (T, error)) R[T]
- func (r R[T]) SafeTee(f func(T)) R[T]
- func (r R[T]) Tee(f func(T) error) R[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exception ¶
type Exception struct {
E interface{}
}
Exception is a type encapsulating anything contained in panic. It implements Error() and therefore can be used as error.
type R ¶
R is a simplification of Either monad. It’s either succesful—when its error is nil—or unsuccessful otherwise.
func (R[T]) Bind ¶
Bind performs f on the receiver’s success value and assigns the returned value and error to the receiver if it’s is successful. In either case, Bind returns the receiver. Bind operates on functions that return value and error.
func (R[T]) Catch ¶
Catch performs f on the receiver’s success value and assigns the returned vale to the receiver if it’s successful. If f panics, Catch recovers and stores the value passed to panic in receiver’s error as Exception. In either case, Catch returns the receiver.
func (R[T]) Handle ¶
Handle performs onSuccess on the receiver’s success value if the receiver is successful, or onError on the receiver’s error otherwise. In either case, Handle returns the receiver.
func (R[T]) Map ¶
Map performs f on the receiver’s success value and assigns the returned value to the receiver if it’s is successful. In either case, Map returns the receiver. Map operates on functions that are always successful and return only one value.
func (R[T]) Recover ¶
Revover tries to put processing back on the happy track. If receiver is not successful, Recover calls the passed function and assignes the returned value and error to the receiver. In either case, Recover returns the receiver.
func (R[T]) SafeTee ¶
SafeTee performs f on the receiver’s success value if the receiver is successful. In either case, SafeTee returns the receiver. SafeTee operates on functions that only perform side effects and are always successful.