Skip to content

cmapMIf and cmapM_If #71

@jeyj0

Description

@jeyj0

Is there a reason cmapMIf and cmapM_If are not implemented (other than: they didn't seem necessary, or nobody has needed them yet)?
I just tried implementing cmapM_If myself, but maybe they should actually be included in the library itself? What do you think?


Here's my attempt at an implementation for cmapM_If (It doesn't compile though, and I'm too much of a haskell beginner to fix it...):

cmapM_If :: forall w m cp c.
  ( Get w m cp
  , Get w m c
  , Members w m c
  )
  => (cp -> Bool)
  -> (c -> SystemT w m ())
  -> SystemT w m ()
cmapM_If cond sys = do
  sp :: Storage cp <- getStore
  s :: Storage c <- getStore
  sl <- lift $ explMembers (s, sp)
  U.forM_ sl $ \ety -> do
    p <- explGet sp ety
    when (cond p) $ do
      x <- lift $ explGet s ety
      sys x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions