Skip to content

Commit e27f26e

Browse files
author
Your Name
committed
Backtrack different instance shapes
1 parent d8a62fa commit e27f26e

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/Hell.hs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -789,18 +789,21 @@ lookupDict rep crep =
789789
-- Cases that look like: Semigroup (Vector (e :: *))
790790
-- Note: the kinds are limited to this exact specification in the signature above.
791791
| Type.App t _ <- rep,
792-
Just Type.HRefl <- Type.eqTypeRep (typeRepKind t) (TypeRep @(Type -> Type)) ->
793-
resolve1 (Type.App crep rep) crep t instances
792+
Just Type.HRefl <- Type.eqTypeRep (typeRepKind t) (TypeRep @(Type -> Type)),
793+
Just dict <- resolve1 (Type.App crep rep) crep t instances ->
794+
pure dict
794795
-- Cases that look like: Monad (Either (e :: *) (a :: *))
795796
-- Note: the kinds are limited to this exact specification in the signature above.
796797
| Type.App t _ <- rep,
797-
Just Type.HRefl <- Type.eqTypeRep (typeRepKind t) (TypeRep @(Type -> Type -> Type)) ->
798-
resolve1 (Type.App crep rep) crep t instances
798+
Just Type.HRefl <- Type.eqTypeRep (typeRepKind t) (TypeRep @(Type -> Type -> Type)),
799+
Just dict <- resolve1 (Type.App crep rep) crep t instances ->
800+
pure dict
799801
-- Cases that look like: Semigroup (Mod (f :: * -> *) (a :: *))
800802
-- Note: the kinds are limited to this exact specification in the signature above.
801803
| Type.App (Type.App t _a) _b <- rep,
802-
Just Type.HRefl <- Type.eqTypeRep (typeRepKind t) (TypeRep @((Type -> Type) -> Type -> Type)) ->
803-
resolve2 (Type.App crep rep) crep t instances
804+
Just Type.HRefl <- Type.eqTypeRep (typeRepKind t) (TypeRep @((Type -> Type) -> Type -> Type)),
805+
Just dict <- resolve2 (Type.App crep rep) crep t instances ->
806+
pure dict
804807
-- Simple cases: Eq (a :: k)
805808
| otherwise ->
806809
resolve crep rep instances

0 commit comments

Comments
 (0)