Skip to content

Provide optics? #38

@hasufell

Description

@hasufell

I tried to get all top-level assignments and ended up with:

extractAssignments :: List -> [Assign]
extractAssignments (List stms) = join $ fmap getAssign $ getCommands stms
 where
  getCommands :: [Statement] -> [Command]
  getCommands = join . fmap commands . catMaybes . fmap findPipes
   where
    findPipes (Statement (Last p@(Pipeline{})) Sequential) = Just p
    findPipes _ = Nothing

  getAssign :: Command -> [Assign]
  getAssign (Command (SimpleCommand ass _) _) = ass
  getAssign _ = []

I believe this would be easier with optics. I would propose the optics package, because it has better documentation, an opaque interface with useful type errors and safer behavior in some corner cases (e.g. less implicit monoidal behavior) than lens.

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