Created
August 30, 2019 04:04
-
-
Save fumieval/058cca68eab1dcdc922e99d776acfd91 to your computer and use it in GitHub Desktop.
Can't derive Generic1 though
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FieldNamesB b where | |
bFieldNames :: IsString a => b (Const a) | |
default bFieldNames :: (Generic1 b, FieldNamesB (Rep b), IsString a) => b (Const a) | |
bFieldNames = to bFieldNames | |
instance FieldNamesB U1 where | |
bFieldNames = U1 | |
instance (FieldNamesB t) => FieldNamesB (M1 C m t) where | |
bFieldNames = M1 bFieldNames | |
instance (FieldNamesB t) => FieldNamesB (M1 D m t) where | |
bFieldNames = M1 bFieldNames | |
instance (FieldNamesB f, FieldNamesB g) => FieldNamesB (f :*: g) where | |
bFieldNames = bFieldNames :*: bFieldNames | |
instance (m ~ 'MetaSel ('Just name) su ss ds, IsString a, KnownSymbol name) => FieldNamesB (M1 S m (Rec1 (Const a))) where | |
bFieldNames = M1 $ Rec1 $ Const $ fromString $ symbolVal (Proxy :: Proxy name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment