Created
January 19, 2022 03:36
-
-
Save psilospore/71726d505a98c821136643ae43937953 to your computer and use it in GitHub Desktop.
Get list of property names from a Haskell Record
This file contains 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
{-# LANGUAGE DeriveDataTypeable #-} | |
import qualified Data.Data as D | |
import Data.Data (Data) | |
data Gurren = Gurren { | |
owner :: String | |
, spiralPower :: Natural | |
} deriving (Data) | |
let properties = D.constrFields . head . D.dataTypeConstrs $ D.dataTypeOf (undefined :: Gurren) | |
-- ["owner", "spiralPower"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment