Hoogle Search
Within LTS Haskell 24.5 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
exceptions Control.Monad.Catch Flipped catchJust. See Control.Exception's handleJust.
tryJust :: (HasCallStack, MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)exceptions Control.Monad.Catch A variant of try that takes an exception predicate to select which exceptions are caught. See Control.Exception's tryJust
_Just :: forall a b p f . (Choice p, Applicative f) => p a (f b) -> p (Maybe a) (f (Maybe b))lens Control.Lens.Combinators This Prism provides a Traversal for tweaking the target of the value of Just in a Maybe.
>>> over _Just (+1) (Just 2) Just 3
Unlike traverse this is a Prism, and so you can use it to inject as well:>>> _Just # 5 Just 5
>>> 5^.re _Just Just 5
Interestingly,m ^? _Just ≡ m
>>> Just x ^? _Just Just x
>>> Nothing ^? _Just Nothing
_Just :: forall a b p f . (Choice p, Applicative f) => p a (f b) -> p (Maybe a) (f (Maybe b))lens Control.Lens.Prism This Prism provides a Traversal for tweaking the target of the value of Just in a Maybe.
>>> over _Just (+1) (Just 2) Just 3
Unlike traverse this is a Prism, and so you can use it to inject as well:>>> _Just # 5 Just 5
>>> 5^.re _Just Just 5
Interestingly,m ^? _Just ≡ m
>>> Just x ^? _Just Just x
>>> Nothing ^? _Just Nothing
_Just :: forall a b p f . (Choice p, Applicative f) => p a (f b) -> p (Maybe a) (f (Maybe b))gogol-core Gogol.Prelude This Prism provides a Traversal for tweaking the target of the value of Just in a Maybe.
>>> over _Just (+1) (Just 2) Just 3
Unlike traverse this is a Prism, and so you can use it to inject as well:>>> _Just # 5 Just 5
>>> 5^.re _Just Just 5
Interestingly,m ^? _Just ≡ m
>>> Just x ^? _Just Just x
>>> Nothing ^? _Just Nothing
catchJust :: (MonadUnliftIO m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m aunliftio UnliftIO.Exception catchJust is like catch but it takes an extra argument which is an exception predicate, a function which selects which type of exceptions we're interested in.
handleJust :: (MonadUnliftIO m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m aunliftio UnliftIO.Exception Flipped catchJust.
tryJust :: (MonadUnliftIO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)unliftio UnliftIO.Exception A variant of try that takes an exception predicate to select which exceptions are caught.
_Just :: forall a a' f . Applicative f => (a -> f a') -> Maybe a -> f (Maybe a')microlens Lens.Micro _Just targets the value contained in a Maybe, provided it's a Just. See documentation for _Left (as these 2 are pretty similar). In particular, it can be used to write these:
- Unsafely extracting a value from a Just:
fromJust = (^?! _Just)
- Checking whether a value is a Just:
isJust = has _Just
- Converting a Maybe to a list (empty or consisting of a single element):
maybeToList = (^.. _Just)
- Gathering all Justs in a list:
catMaybes = (^.. each . _Just)
elemIndexJust :: (Partial, Eq a) => a -> [a] -> Intsafe Safe elemIndexJust op = fromJust . elemIndex op