Created
December 4, 2017 08:52
-
-
Save AdamSaleh/5099b2f860e2af6401ec1b562364d280 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
class SemigroupJoinRecord rl rl2 row row' row'' | |
| rl -> row, rl2 -> row', rl rl2 -> row'' | |
where | |
appendJoinRecordImpl :: RLProxy rl -> RLProxy rl2 -> Record row -> Record row' -> Record row'' | |
instance appendJoinRecordCons :: | |
( IsSymbol name | |
, Semigroup ty | |
, RowCons name ty trash row | |
, SemigroupJoinRecord tail other' row row' tailRow'' | |
, RowListRemove name other other' | |
, ListToRow other' row' | |
, RowLacks name tailRow'' | |
, RowCons name ty tailRow'' row'' | |
) => SemigroupJoinRecord (Cons name ty tail) other row row' row'' where | |
appendJoinRecordImpl _ _ a b = | |
insert namep valC rest | |
where | |
namep = SProxy :: SProxy name | |
valA = get namep a | |
valB = get namep b | |
valC = valA <> valB | |
tailp = RLProxy :: RLProxy tail | |
otherp' = RLProxy :: RLProxy other' | |
rest = appendJoinRecordImpl tailp otherp' a b | |
instance appendJoinRecordANil :: | |
SemigroupJoinRecord other Nil row row' row where | |
appendJoinRecordImpl _ _ a _ = a | |
instance appendJoinRecordNilB :: | |
SemigroupJoinRecord Nil other row row' row' where | |
appendJoinRecordImpl _ _ _ b = b | |
appendJoinRecord :: forall row row' row'' rl rl2 | |
. RowToList row rl | |
=> RowToList row' rl2 | |
=> SemigroupJoinRecord rl rl2 row row' row'' | |
=> Record row | |
-> Record row' | |
-> Record row'' | |
appendJoinRecord a b = appendJoinRecordImpl (RLProxy :: RLProxy rl) (RLProxy :: RLProxy rl2) a b | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment