Hoogle Search

Within LTS Haskell 24.20 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. takeWhileJust :: [Maybe a] -> [a]

    utility-ht Data.List.HT

    This is the cousin of takeWhile analogously to catMaybes being the cousin of filter.

    >>> takeWhileJust [Just 'a', Just 'b', Nothing, Just 'c']
    "ab"
    
    Example: Keep the heads of sublists until an empty list occurs.
    >>> takeWhileJust $ map (fmap fst . viewL) ["abc","def","","xyz"]
    "ad"
    
    For consistency with takeWhile, partitionMaybe and dropWhileNothing it should have been:
    takeWhileJust_ :: (a -> Maybe b) -> a -> [b]
    
    However, both variants are interchangeable:
    takeWhileJust_ f == takeWhileJust . map f
    takeWhileJust == takeWhileJust_ id
    

  2. catchJust :: (HasCallStack, MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a

    safe-exceptions Control.Exception.Safe

    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.

  3. handleJust :: (HasCallStack, MonadCatch m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a

    safe-exceptions Control.Exception.Safe

    Flipped catchJust.

  4. tryJust :: (HasCallStack, MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)

    safe-exceptions Control.Exception.Safe

    A variant of try that takes an exception predicate to select which exceptions are caught.

  5. untilJust :: Monad m => m (Maybe a) -> IterT m a

    free Control.Monad.Trans.Iter

    Repeatedly run a computation until it produces a Just value. This can be useful when paired with a monad that has side effects. For example, we may have genId :: IO (Maybe Id) that uses a random number generator to allocate ids, but fails if it finds a collision. We can repeatedly run this with

    retract (untilJust genId) :: IO Id
    

  6. belongsToJust :: forall ent1 ent2 backend (m :: Type -> Type) . (PersistStoreRead backend, PersistEntity ent1, PersistRecordBackend ent2 backend, MonadIO m) => (ent1 -> Key ent2) -> ent1 -> ReaderT backend m ent2

    persistent Database.Persist.Class

    Same as belongsTo, but uses getJust and therefore is similarly unsafe.

  7. getJust :: forall record backend (m :: Type -> Type) . (PersistStoreRead backend, PersistRecordBackend record backend, MonadIO m) => Key record -> ReaderT backend m record

    persistent Database.Persist.Class

    Same as get, but for a non-null (not Maybe) foreign key. Unsafe unless your database is enforcing that the foreign key is valid.

    Example usage

    With schema-1 and dataset-1,
    getJustSpj :: MonadIO m => ReaderT SqlBackend m User
    getJustSpj = getJust spjId
    
    spj <- getJust spjId
    
    The above query when applied on dataset-1, will get this record:
    +----+------+-----+
    | id | name | age |
    +----+------+-----+
    |  1 | SPJ  |  40 |
    +----+------+-----+
    
    getJustUnknown :: MonadIO m => ReaderT SqlBackend m User
    getJustUnknown = getJust unknownId
    
    mrx <- getJustUnknown This just throws an error.

  8. getJustEntity :: forall record backend (m :: Type -> Type) . (PersistEntityBackend record ~ BaseBackend backend, MonadIO m, PersistEntity record, PersistStoreRead backend) => Key record -> ReaderT backend m (Entity record)

    persistent Database.Persist.Class

    Same as getJust, but returns an Entity instead of just the record.

    Example usage

    With schema-1 and dataset-1,
    getJustEntitySpj :: MonadIO m => ReaderT SqlBackend m (Entity User)
    getJustEntitySpj = getJustEntity spjId
    
    spjEnt <- getJustEntitySpj
    
    The above query when applied on dataset-1, will get this entity:
    +----+------+-----+
    | id | name | age |
    +----+------+-----+
    |  1 | SPJ  |  40 |
    +----+------+-----+
    

  9. belongsToJust :: forall ent1 ent2 backend (m :: Type -> Type) . (PersistStoreRead backend, PersistEntity ent1, PersistRecordBackend ent2 backend, MonadIO m) => (ent1 -> Key ent2) -> ent1 -> ReaderT backend m ent2

    persistent Database.Persist.Class.PersistStore

    Same as belongsTo, but uses getJust and therefore is similarly unsafe.

  10. getJust :: forall record backend (m :: Type -> Type) . (PersistStoreRead backend, PersistRecordBackend record backend, MonadIO m) => Key record -> ReaderT backend m record

    persistent Database.Persist.Class.PersistStore

    Same as get, but for a non-null (not Maybe) foreign key. Unsafe unless your database is enforcing that the foreign key is valid.

    Example usage

    With schema-1 and dataset-1,
    getJustSpj :: MonadIO m => ReaderT SqlBackend m User
    getJustSpj = getJust spjId
    
    spj <- getJust spjId
    
    The above query when applied on dataset-1, will get this record:
    +----+------+-----+
    | id | name | age |
    +----+------+-----+
    |  1 | SPJ  |  40 |
    +----+------+-----+
    
    getJustUnknown :: MonadIO m => ReaderT SqlBackend m User
    getJustUnknown = getJust unknownId
    
    mrx <- getJustUnknown This just throws an error.

Page 34 of many | Previous | Next