parsonsmatt / prairie

First Class Record Fields in Haskell
BSD 3-Clause "New" or "Revised" License
17 stars 4 forks source link

Replace lists with `NonEmpty` - or, do we allow no-field records? #7

Open parsonsmatt opened 8 months ago

parsonsmatt commented 8 months ago

There are a few types that use [] instead of NonEmpty, which (while convenient) restrict the utility.

For example, allFields is allFields :: (Record rec) => [SomeField rec]. However, if we don't allow empty Records, then we can write that as NonEmpty (SomeField rec), which is much nicer - we can use sconcat and Semigroup classes generally.

parsonsmatt commented 8 months ago

oh, hm, allFields currently uses the Const applicative, which does require a Monoid, and is thus []. This is because tabulateRecordA is defined for Applicative, which must support pure.

allFields could be a class method again for this, which would allow Semigroup combinations. But I think I can punt this.