digitallyinduced/ihp

IHP codegen does not enforce capitalised View names

Opened this issue · 3 comments

The steps I took, as an IHP beginner, just working with the web console:

  1. Created a table named users, using CodeGen
  2. Clicked CodeGen in the console, then Controller
  3. Entered users in the Controller name text box (notice the console corrects usersUsers so it's capitalised)
  4. This all seemed to work, so I went to CodeGen again, and selected Users from the drop-down. I was unsure what it meant precisely to create a View in this context, so in the View name text box I entered test.
  5. Clicked Preview then Generate

The CodeGen failed to generate valid Haskell code (since type and module names cannot be lowercase). The attached screenshot shows the Preview step, including the invalid code.

image

What I would expect to happen: IHP console should auto-capitalise the contents of View name, like it does when creating a Controller.

Also, I successfully reproduced this bug on master (love the new console gui when you run ./start. So slick!)

Thanks, good catch 👍

Looks like the error is here: https://github.com/digitallyinduced/ihp/blob/master/IHP/IDE/CodeGen/ViewGenerator.hs#L83C24-L83C38

The {$nameWithSuffix} will always produce something like data X = {X} which is always invalid haskell. I guess it's just a typo and should be ${nameWithSuffix}

Thanks for the reply! Seems like a good beginner issue, so I'd like to have a go at fixing it.

Aside: it took me ~10 minutes of re-reading your last comment to see the difference between {$nameWithSuffix} and ${nameWithSuffix}, so I'm not surprised this issue came up!