i-am-tom / higgledy

Higher-kinded data via generics
MIT License
170 stars 20 forks source link

A version of HKD which doesn't wrap a field in `f` if its already wrapped in same f #22

Open epicallan opened 4 years ago

epicallan commented 4 years ago

Say I have a type

data User = User 
  {  name :: Last String 
  ,  age  :: Int  
  } 

Would you be open to having a version of HKD say HKD' which wouldn't wrap name in f but wraps the remaining fields.

type PartialUser = HKD' User Last

I could take a stab at an implementation of a PR to this effect if it's agreeable to you.

i-am-tom commented 4 years ago

This is actually really tricky - the problem is that the rep transformation is no longer injective, so type inference really degrades as a result. This is also why there's no instance of GHKD_ for unital or void types :(

More than happy to help out if you want to try it, though! I've been meaning to take another look at nested HKDs forever, and the same problem applies, so any progress would be cool!