smaccoun / create-haskstar-app

Create fullstack haskell apps in one command!
BSD 3-Clause "New" or "Revised" License
21 stars 2 forks source link

Miso scaffolding #1

Open dmjio opened 6 years ago

dmjio commented 6 years ago

I'd like this for miso, would be cool to have the following wrapped-up in one command:

Choosing which db library to use will be tough, have heard good things about beam though... acid-state with the remote backend could be an option. Either way making a Context datatype (like a mock of db operations to get inversion of control) would be ideal. So the user could swap out backend implementations.

data Context
  = Context
  { updateUser :: (User -> User) -> IO ()
  , getWidgetsByUserId :: UserId -> IO [Widget]
  }
  -- etc..

But yea, a scaffolding using nix would be ideal, where the user could just do a nixops deploy would be huge.

smaccoun commented 6 years ago

Edit - Just updated README roadmap based on your suggestions

Miso was actually the first front-end I wanted to use, but I'm building this mostly internally right now for some Elm apps. If there is an ideal Miso scaffold to work off of I could probably get that in fairly quickly. The way I'm structuring this now is that each pluggable part of the framework (for back-end and front-end) will point to an ideal templated/scaffold repo (see e.g. haskstar-elm).

This project is a bit hacked together ATM (as you can probably see by the turtle script), but I would love all that you suggested and I do plan on making this highly usable for as many people as possible. I am not very familiar with deployment scripts via nix but I'll start studying them as that does seem preferable. Responses to other points:

Re DB - You're telling me, I used Opaleye in production with my last company and - though it is very powerful - it is loaded with boilerplate. From the looks of it, Selda to me looks like the cleanest API with the best feature set. Funny enough, as you were writing this I saw your selda-servant repo and I am just now playing with how Servant will interact with Selda (there is a github issue open for it currently) I'm not sure about Beam - have seen it before but can't remember where I landed on it. My dream scenario is that I can roughly autogenerate ORM table setups from the migrations, and that the db will actually be type-checked against the haskell models. Persistent/Esquelito is another option

The Context type is exactly what I was thinking....will see how well it works in practice but I think it should be quite doable. I will probably be a bit partial to get it working well with one library first (like Selda), and then start abstracting out what is needed to plugin other libs.

One other thing I'm adding to the roadmap is an auto built GUI for one click deployments and doing things like capturing db stats before and after. Have a lot of ideas around that

I'll start studying up on nix ops tonight, unless you have a quick way of doing it and want to PR it. I'll be working on this heavily over the next month, and if you want to contribute any of the above would be amazing :)