IHP 1.0 is out now!

Making a simple form type-safe


Posted a question to the stackoverflow ihp tag:


This one builds on the simple temperature conversion app I posted in my last question. The idea here is to have the form be generated in a type-safe manner, hopefully showing off IHP a little bit more. The type-safe form generation helpers are a nice feature of IHP and make it stand out amongst peer frameworks.

Any suggestions welcome there or here.



It's working!

I've updated the question to show the updates I made to make the example function.


As mentioned there, it's a little awkward to have to add the unused id and meta fields in Temperature just to satisfy the form generation code:

data Temperature = Temperature { 
    id :: Int, 
    farenheit :: Float, 
    meta :: MetaBag 
} deriving (Show)

Ideally we'd be able to leave those out.


Is it conceivable that someday the form generation feature would be able to work without the id and meta fields? I.e. this way the Temperature record would just be:

data Temperature = Temperature { 
    farenheit :: Float
} deriving (Show)

If so, I'll be happy to open a github issue for this.

Or do you think that the presence of those fields is mandatory for the type-safe form generation feature?

marc PRO

Glad you figured this one out :)

The id can be removed in the future.

The meta is currently used for storing the validation results. So this field is unlikely to go away.