circuithub / rel8

Hey! Hey! Can u rel8?
https://rel8.readthedocs.io
Other
150 stars 38 forks source link

[Question] What does the `NonEmpty String` list contain in `namesFromLabelsWith`? #276

Closed sir4ur0n closed 9 months ago

sir4ur0n commented 9 months ago

Function namesFromLabelsWith takes as argument a function that receives a NonEmpty String, but the documentation does not explain what this list contains. The documented example just takes the last value of that list to obtain the Haskell type.

I have fiddled with this function in a REPL but I always get back a list of exactly 1 element.

Can you explain (and ideally, add to the function documentation) what this list may contain, besides the last element always being the Haskell field name?

shane-circuithub commented 9 months ago

If you have a Rel8able like:


data Foo f = Foo
  { a :: Column f Bool
  , b :: Column f Char
  }
  deriving (Generic, Rel8able)

data Bar f = Bar
  { foo1 :: Foo f
  , foo2 :: Foo f
  }
  deriving (Generic, Rel8able)

Then the argument passed to namesFromLabelsWith will contain things like ["foo1", "a"], ["foo1", "b"], ["foo2", "a"], ["foo2", "b"].