Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving statics #88

Open
bergmark opened this issue Nov 12, 2014 · 1 comment
Open

Improving statics #88

bergmark opened this issue Nov 12, 2014 · 1 comment
Labels

Comments

@bergmark
Copy link
Member

It's currently error-prone to use statics and I've made this mistake several times:

data Static = X | Y

resource :: Resource WithA WithB Ident Void Static
resource = mkResourceReader
  { R.name    = "foo"
  , R.schema  = noListing $ named
      [ ("id"          , singleRead ById  )
      , ( "x"          , static X         )
      ]
  , R.get     = Just get
  , R.statics = \case
      X -> x
      Y -> y
  }

This is missing a route to Y so this end point will be inaccessible and you won't get a warning.
Actions and selects do not have this problem since they don't require entries in both schema and actions.

Is there a reason statics are handled differently? Could we remove statics from schema and change the type of statics to [(String, Handler)]?

@hesselink
Copy link
Member

This is a broader problem, you can have the same with normal getters and listings. One issue I can think of with moving the statics outside of the schema is that it would be much easier to accidentally create overlapping schemas, where a static and a getter/list use the same key name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants