私はGHC 7.10.x Migrationについての記事を読んでいました。エラーを修正するためのいくつかの提案があります。GHC 7.10.xの移行:なぜApplicativeインスタンスに "pure = return"と書くことができませんか?
GHCその
Foo.hs訴える場合GHCは
No instance for (Applicative ...)
を言う:7:10:インスタンス宣言は、インスタンス宣言 のスーパークラスから生じる(ApplicativeのFooの)ため なしインスタンス'Monad Foo'の場合、このエラーを簡単に解決するには、Applicative(とFunctor)を定義することです: fmap = liftM - または代わりに -fマップ= m >> =純粋。
instance Applicative Foo where -- NB: DO NOT USE `pure = return` pure = {- move the definition of `return` from the `Monad` instance here -} (<*>) = ap {- defined in Control.Monad -} -- or alternatively: -- f1 <*> f2 = f1 >>= \v1 -> f2 >>= (pure . v1) -- NB: DO NOT USE `(*>) = (>>)` (*>) = {- move the definition of `>>` from the `Monad` instance here -} instance Monad Foo where return = pure {- definition moved to `Applicative(pure)` -} (>>) = (*>) {- definition moved to `Applicative((*>))` -} {- ...retain other previous definitions... -}
fはNBSがあります。DO NOT USE `pure = return`
とDO NOT USE `(*>) = (>>)
。なぜそれを使うことができないのですか?
P.S.私はそれを使用しようとし、コンパイルされています。
これは再帰的な定義につながります: 'Monad'インスタンス関数は' Applicative'インスタンス関数の観点から定義されているので、逆もできません。 –