可以使用以下方法消除歧义:
ScopedTypeVariables+TypeApplications
reify2
,将类型参数放在第一位以将其放入范围。
{-# LANGUAGE AllowAmbiguousTypes, RankNTypes, ConstraintKinds, GADTs, ScopedTypeVariables, TypeApplications, TypeOperators #-}
data Dict c where
Dict :: c => Dict c
data c :- d where
Sub :: (c => Dict d) -> c :- d
reify2 :: forall r3 c c' a. c' r3 =>
(forall r1. c' r1 :- c r1) ->
(forall r2. c r2 => a) ->
a
reify2 cons f =
case cons @r3 of
Sub Dict -> f @r3