bitemyapp / esqueleto

New home of Esqueleto, please file issues so we can get things caught up!
BSD 3-Clause "New" or "Revised" License
370 stars 107 forks source link

Add a constructor for null values to the 'ToMaybe' type class #271

Open arthurxavierx opened 3 years ago

arthurxavierx commented 3 years ago

I think it'd be great if just and nothing worked for any ToMaybe a => a. We already have just ≡ toMaybe @(SqlExpr (Value a)), but no analogous for nothing exists in ToMaybe. This enhanced version of ToMaybe would enable us to inject null entities for example.

arthurxavierx commented 3 years ago

Having an eliminator in ToMaybe akin to Haskell's maybe would be interesting too, but is it possible to have that for any SqlExpr (Entity e)?

Btw I can work on this ticket soonish if the maintainers are ok with it.