所以我输入了这个
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies #-}
import Data.Monoid
class Monoid m => Mconcat m a | a -> m where
mcon :: m -> a
instance Monoid m => Mconcat m m where
mcon m = m
instance Mconcat m a => Mconcat m (m -> a) where
mcon m m' = mcon (m `mappend` m')
我得到
[1 of 1] Compiling Main ( pad.hs, interpreted )
pad.hs:8:10:
Functional dependencies conflict between instance declarations:
instance Monoid m => Mconcat m m -- Defined at pad.hs:8:10
instance Mconcat m a => Mconcat m (m -> a)
-- Defined at pad.hs:11:10
Failed, modules loaded: none.
事情是,但m
不能m->a
平等!为什么它给我一个冲突?(另外,关于如何制作多变量 mconcat 的任何提示(以printf
图书馆的风格)?