0

具有以下自定义新类型:

newtype QueryM a = QueryM (Connection -> IO a) 

如何Alternative在约束它的同时为它a声明一个实例Alternative?或者我可以吗?

我的意思是这样的:

instance (Alternative a) => Alternative (QueryM a) where
4

1 回答 1

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
于 2012-11-29T04:54:00.353 回答