拥有以下自定义新类型:
newtype QueryM a = QueryM (Connection -> IO a)
如何在限制Alternative
拥有a
实例的同时为其声明Alternative
个实例?或者我可以吗?
我的意思是这样的:
instance (Alternative a) => Alternative (QueryM a) where
答案 0 :(得分:4)
如果我在a
添加参数,请在此处编译好:
import Control.Applicative
newtype QueryM a b = QueryM (Connection -> IO (a b))
type Connection = ()
instance Functor (QueryM a)
instance Applicative (QueryM a)
instance (Alternative a) => Alternative (QueryM a) where