Skip to content

Commit

Permalink
Instance.hs: Use Carrier type alias where it fits. #148
Browse files Browse the repository at this point in the history
  • Loading branch information
epost committed Aug 22, 2019
1 parent a287861 commit 80a9a6b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Language/CQL/Instance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,14 @@ deriving instance TyMap Ord '[en, fk, att, gen, sk] => Ord (TalgGen en fk att ge

deriving instance TyMap Eq '[fk, att, gen, sk] => Eq (TalgGen en fk att gen sk)

-- TODO move to Collage? Algebra?
-- TODO move to Collage? Algebra?
-- TODO move to Collage? Algebra?
close
:: (MultiTyMap '[Show, Ord, NFData] '[var, ty, sym, en, fk, att, gen, sk])
=> Collage var ty sym en fk att gen sk
-> (EQ var ty sym en fk att gen sk -> Bool)
-> [Term Void Void Void en fk Void gen Void]
-> [Carrier en fk gen]
close col dp' =
y (close1m dp' col) $ fmap Gen $ Map.keys $ cgens col
where
Expand All @@ -290,21 +293,21 @@ close1m
=> (EQ var ty sym en fk att gen sk -> Bool)
-> Collage var ty sym en fk att gen sk
-> t (Term Void Void Void en fk Void gen Void)
-> [Term Void Void Void en fk Void gen Void]
-> [Carrier en fk gen]
close1m dp' col = dedup dp' . concatMap (close1 col dp')

dedup
:: (EQ var ty sym en fk att gen sk -> Bool)
-> [Term Void Void Void en fk Void gen Void]
-> [Term Void Void Void en fk Void gen Void]
-> [Carrier en fk gen]
-> [Carrier en fk gen]
dedup dp' = nubBy (\x y -> dp' (EQ (upp x, upp y)))

close1
:: (MultiTyMap '[Show, Ord, NFData] '[var, ty, sym, en, fk, att, gen, sk])
=> Collage var ty sym en fk att gen sk
-> (EQ var ty sym en fk att gen sk -> Bool)
-> Term Void Void Void en fk Void gen Void
-> [Term Void Void Void en fk Void gen Void]
-> Carrier en fk gen
-> [Carrier en fk gen]
close1 col _ e = e:(fmap (\(x,_) -> Fk x e) l)
where
t = typeOf col e
Expand Down

0 comments on commit 80a9a6b

Please sign in to comment.