tomjaguarpaw / haskell-opaleye

Other
599 stars 115 forks source link

Delete no longer relevant tutorial sections #582

Closed jhrcek closed 8 months ago

jhrcek commented 8 months ago

All of these "would you like to volunteer to implement this missing feature" comments seem no longer relevant, because the mentioned features have already been implemented (please correct me if I'm wrong).

jhrcek commented 8 months ago

Hm, didn't realize the generic stuff is not implemented for monomorphic types. Could you please sketch what exactly should be implemented using generics? I mean in the form like

instance (... some context) => Default what1 what2 what3 where ...

I might give it a try as a learning project :smile: I understand the general technique of using default instance methods + DeriveAnyClass, just not sure what exactly you mean by "this is all derivable by Generics"..

tomjaguarpaw commented 8 months ago

Thank you!

tomjaguarpaw commented 8 months ago

Hm, didn't realize the generic stuff is not implemented for monomorphic types. Could you please sketch what exactly should be implemented using generics?

Could you clarify the question? What needs to be implemented is derivation of exactly the code from that section of the tutorial, that is, define a "birthday" type with two fields, a "text" and a "date" and generate from it the following code

> data BirthdayField = BirthdayField { bdNameField :: Field SqlText
>                                      , bdDayField  :: Field SqlDate }
>
> data Birthday = Birthday { bdName :: String, bdDay :: Day }
>
> birthdayFieldDef ::
>   (Applicative (p BirthdayField),
>    P.Profunctor p,
>    Default p (Field SqlText) (Field SqlText),
>    Default p (Field SqlDate) (Field SqlDate)) =>
>   p BirthdayField BirthdayField
> birthdayFieldDef = BirthdayField <$> P.lmap bdNameField D.def
>                                    <*> P.lmap bdDayField  D.def
>
> instance Default Unpackspec BirthdayField BirthdayField where
>   def = birthdayFieldDef