import Control.Lens
-- is there a way I can write top-level definitions
-- in an arbitrary order like
px = proto & _1 %~ asTypeOf '2'
py = proto & _2 %~ asTypeOf "2"
proto = (undefined, undefined)
-- but have types inferred like the following:
(qx,qy,qroto) = case (undefined, undefined) of
qxy -> (qxy & _1 %~ asTypeOf '2',
qxy & _2 %~ asTypeOf "2",
qxy)
我得到了想要的qroto :: (Char, [Char])
,但proto :: (t, t1)
太笼统了。更重要的是,这导致px :: (Char, t)
而不是qx :: (Char, [Char])
.
更大的问题是我试图减少Data.HList.Variant.mkVariant的第三个参数所需的类型注释。