TypeFamilyDependencies
この拡張を有効にしていないと怒られるケース
そこでこの拡張を使うことで、単射を強制できる
逆に、type family depを付けずに、type familyを使う利点はあるの
#??言い方を変えれば、常にtype family depを有効にしているせいで生じる問題はあるの?
この拡張は何?単射であることを強制するだけ?
type synonymに対してはType Family Depsの拡張を使うとか?
複雑やなー

単射な例
hstype family F a
type instance F Int = Integer
type instance F Float = Double
f(a)=f(b) \Rightarrow a=bが成り立っているのがわかる
右辺を見れば、左辺を特定できる
F a
が Integer
だとわかれば、 a
は Int
だとわかる
こう書く
hs{-# LANGUAGE TypeFamilyDependencies #-}
type family F a = r | r -> a
type instance F Int = Integer
type instance F Float = Double
hsdata family F a
data instance F Int = F1 Integer
data instance F Float = F2 Double
F1
, F2
のような値コンストラクタを作るので、自明に単射になる
の読みメモ