Skip to content

Error handling recommendations? #10

@Anrock

Description

@Anrock

It's unclear how one should handle failures in previous steps. Is there any recommended way to do it?

Using the example from readme, what if Parse was instead FilePath -> Query (Either ParseError AST), what should happen in Typecheck if Parse returned Left?

data Query a where
  Parse :: FilePath -> Query (Either ParseError AST)
  Typecheck :: FilePath -> Query (Either TypeError TypedAST)

rules :: Rock.Rules Query
rules key = case key of
  Parse file -> do
    _ -- parse the file..
  Typecheck file -> do
    ast <- Rock.fetch (Parse file)
    _ -- typecheck file..

It seems sixten constructs a dummy value for result and uses Writer to store errors from previous steps. Are there other approaches?

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