Endo Ryunosuke / minerva
Bifunctor って第一引数を固定すると Functor になると思うんですが,そういうインスタンス定義は提供されてないみたいなので,instance Bifunctor f => Functor (f a) where fmap = second
と書いてみるとこれはコンパイル通りません.エラーメッセージは
[1 of 1] Compiling Main ( adv.hs, interpreted )
adv.hs:70:25: error:
• Illegal instance declaration for 'Functor (f a)'
(All instance types must be of the form (T a1 ... an)
where a1 ... an are *distinct type variables*,
and each type variable appears at most once in the instance head.
Use FlexibleInstances if you want to disable this.)
• In the instance declaration for 'Functor (f a)'
|
70 | instance Bifunctor f => Functor (f a) where
| ^^^^^^^^^^^^^
Failed, no modules loaded.で,指示通り
{-# LANGUAGE FlexibleInstances #-} をつけるとコンパイルは通りますが,デフォルトだとなんでこんな制約があるんでしょう?