Created
July 17, 2018 06:40
-
-
Save paulvictor/418c74aba40e0ff989440e19eb2c66b8 to your computer and use it in GitHub Desktop.
Record subset
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 RowSubset (row :: # Type) (xs :: RowList) (subrow :: # Type) | xs -> subrow where | |
| subsetImpl :: RLProxy xs -> {|row} -> {|subrow} | |
| instance nilRowSubset :: RowSubset row Nil () where subsetImpl _ _ = {} | |
| instance consRowSubset | |
| :: | |
| ( IsSymbol sym | |
| , Cons sym a subrowWithoutSym subrowWithSym | |
| , Cons sym a srcWithoutSym src | |
| , Lacks sym subrowWithoutSym | |
| , RowSubset src rl subrowWithoutSym | |
| ) => RowSubset src (Cons sym a rl) subrowWithSym where | |
| subsetImpl _ src = insert (SProxy :: SProxy sym) (get (SProxy :: SProxy sym) src) (subsetImpl (RLProxy :: RLProxy rl) src) | |
| subsetRow | |
| :: ∀ rl subR src | |
| . ListToRow rl subR | |
| => RowToList subR rl | |
| => RowSubset src rl subR | |
| => {|src} | |
| -> RProxy subR | |
| -> {|subR} | |
| subsetRow src _ = subsetImpl (RLProxy :: RLProxy rl) src |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment