Created
August 26, 2017 00:52
-
-
Save missingfaktor/caa6040728016d61592781d7bfab958d to your computer and use it in GitHub Desktop.
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
| Prelude> -- Poor man's row polymorphism | |
| Prelude> data Employee row = Employee { id :: Int, name :: String, otherFields :: row } deriving Show | |
| Prelude> data SalaryInfo = SalaryInfo Int | |
| Prelude> let e = Employee 12 "Rajguru" (SalaryInfo 10000) | |
| Prelude> :t e | |
| e :: Employee SalaryInfo | |
| Prelude> | |
| Prelude> -- Poor man's column polymorphism | |
| Prelude> data AST column = Num Int | Str String | Other column deriving Show | |
| Prelude> let c = Other (SalaryInfo 11) | |
| Prelude> :t c | |
| c :: AST SalaryInfo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment