compress xs@(_:_:_) = (ifte <$> ((==) <$> head <*> head.tail) <$> ((compress.).(:) <$> head <*> tail.tail) <*> ((:) <$> head <*> compress.tail) ) xs
导致类型错误,但我不明白为什么.它应该相当于
compress xs@(_:_:_) = (ifte (((==) <$> head <*> head.tail) xs) (((compress.).(:) <$> head <*> tail.tail) xs) (((:) <$> head <*> compress.tail) xs))
,没有.
注意:ifte = (\ x y z -> if x then y else z),<$>并<*>从Control.Applicative.
编辑:错误是:
Couldn't match expected type `[a]' with actual type `[a] …Run Code Online (Sandbox Code Playgroud)