silkapp / rest

Packages for defining APIs, running them, generating client code and documentation.

Home Page:http://silkapp.github.io/rest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove `Step` after top level singleton

hesselink opened this issue · comments

Right now, the Schema constructor takes a top level construct (Maybe (Cardinality sid mid)), and a Step. However, when the top level thing is Single, it doesn't make sense to have the subsequent Step: nesting listings and getters on top of a singleton getter is weird, and for statics you can get the same effect with actions. The statics also don't work.

Rather than trying to make the statics work, I propose to remove the Step if the top level thing is a Single. This is a breaking change to Schema (which people probably don't use) and singleton. It would also probably be a bit of work in the router and perhaps rest-gen. @bergmark What do you think?

I don't really know how Schema "works" so I can't really comment on that but the rationale is good.

From an API perspective:

  • What is the current behavior, will end points silently be ignored?
  • What will the behavior be after this change? Type error?
  • Should we add a smart constructor for singletons?

What do you mean how it "works"? It defines the schema (think urls) for the resource.

To answer your bullets:

  • Yes. This is very confusing and is how I found this out.
  • Yes. The signature of singleton will change and it will no longer take a list of steps.
  • We have, it's called singleton. :)

What I meant was that I didn't see the implications of removing the Step.
But this sounds good to me!

Oh and also, i meant having a mkSingleton along with mkResource*, but perhaps that doesn't add much?

No, I don't think so. We have mkResource* because there's no sensible default for the enter function. Schemas have sensible defaults and you can just fill them in with singleton Bla, so I don't see the reason for adding mkSingleton.