Template Haskell Function for Record Accessor Inheritance -


i have 2 datatypes, a , b, have defined as:

data = { afoo :: int, abar :: string } data b = b { bfoo :: int, bbar :: string, bbaz :: float } 

i need create heterogeneous list of as , bs, define sum type, c, as:

data c = ca | cb b 

i define functions

cfoo :: c -> int cbar :: c -> string 

this can achieved pattern matching...

cfoo (ca a) = afoo cfoo (cb b) = bfoo b  cbar (ca a) = abar cbar (cb b) = bbar b 

...but becomes tedious data types of many fields. wondering if there simple solution using template haskell, or if wouldn't worth effort. have intermediate knowledge of haskell, relatively new template haskell. appreciated.


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -