silkapp / rest

Packages for defining APIs, running them, generating client code and documentation.
http://silkapp.github.io/rest
390 stars 52 forks source link

Remove `Step` after top level singleton #113

Open hesselink opened 9 years ago

hesselink commented 9 years ago

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?

bergmark commented 9 years ago

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:

hesselink commented 9 years ago

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

To answer your bullets:

bergmark commented 9 years ago

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

bergmark commented 9 years ago

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

hesselink commented 9 years ago

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.