Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Data/Generic/Diff.hs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,13 @@ class (Family f) => Type f t where
--
-- Use 'Abstr' for abstract constructors (e.g., for built-in types or types with many
-- (or infinite) constructors)
--
-- Use 'Meta' for abstract constructors whose subtrees are of existential type
-- (which means exposing 'ts' is forbidden by the type checker)
data Con :: (* -> * -> *) -> * -> * where
Concr :: (List f ts) => f t ts -> Con f t
Abstr :: (List f ts) => (t -> f t ts) -> Con f t
Meta :: (t -> Con f t) -> Con f t

class List f ts where
list :: IsList f ts
Expand Down Expand Up @@ -313,6 +317,7 @@ matchConstructor = tryEach constructors
(forall ts. f t ts -> IsList f ts -> ts -> r) -> r
tryEach (Concr c : cs) x k = matchOrRetry c cs x k
tryEach (Abstr c : cs) x k = matchOrRetry (c x) cs x k
tryEach (Meta c : cs) x k = tryEach (c x : cs) x k
tryEach [] _ _ = error "Incorrect Family or Type instance."

matchOrRetry :: (List f ts, Type f t) => f t ts -> [Con f t] -> t ->
Expand Down