amitaibu / ihp-cms-starter

5 stars 2 forks source link

Hook to `CanCreate` with `newtype` #23

Closed amitaibu closed 1 year ago

amitaibu commented 1 year ago

I asked on Slack and came up with an answer.

image

I still wonder if it's a valid approach, not sure. @mpscholten What do you think?

mpscholten commented 1 year ago

This breaks the design of what other people would expect createRecord to behave. I'd rather make a new function like createLandingPageWithParagraphCTA :: LandingPage -> IO (LandingPage, ParagraphCta) or createEmptyLandingPage :: LandingPage -> IO (LandingPage, ParagraphCta)

amitaibu commented 1 year ago

:+1:

Yeah, I felt it might be a little weird. I was exploring something similar to Drupal's hook_node_insert - where one can "hook" and operate whenever a new node entity is created.

But I guess createLandingPageWithParagraphCTA aligns more with how Haskell and IHP.

PHP /= Haskell :smile: