是否必須手動打開證據,prj'或者是否有更直接的方法來指導實體求解器?
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE UndecidableInstances #-}
module CatLib.SO.SO_TCMatchingDict where
class OneSide a where oneSide :: a
class (OneSide a {- , ManyOtherTC a -}) => TC a
instance (OneSide a {- , ManyOtherTC a -}) => TC a
class Other f where other :: forall a. f a
instance Other f => OneSide (f x) where oneSide = other
prj :: forall f a. (forall x. TC (f x)) => f a
prj = oneSide @(f a) -- Could not deduce (Other f) arising from a use of ‘oneSide’
prj' :: forall f g tag a b. (forall x. TC (f x)) => f a
prj' = case Dict :: Dict (TC (f a)) of
Dict -> oneSide @(f a) -- that's ok
data Dict c = c => Dict
uj5u.com熱心網友回復:
怎么樣
prj :: forall f a. (forall x. TC (f x)) => f a
prj = go
where
go :: TC (f a) => f a
go = oneSide @(f a)
或者,在一行中:
prj :: forall f a. (forall x. TC (f x)) => f a
prj = oneSide :: TC (f a) => f a
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/428359.html
上一篇:從CssMinimizer版本部署到Jenkins*時出錯:“15.2-15.3”
下一篇:濫用haskell中的where
