7
내가 가지고있는 매우 무고한 보이는 코드 그것은 컴파일하고 잘 작동TypeFamilies 또는 GADTs 갑자기 유효한 코드
data Config = Config
{ cInts :: [Int]
, cStrings :: [String] }
instance Semigroup Config where
c1 <> c2 = Config
{ cInts = andCombiner cInts
, cStrings = andCombiner cStrings }
where
andCombiner field = field c1 <> field c2
나누기. 그러나 나는 TypeFamilies
를 추가하거나 GADTs
확장 나는 아주 이상한 오류가 표시되는 경우 :
.../Main.hs:19:22: error:
• Couldn't match type ‘Int’ with ‘[Char]’
Expected type: [String]
Actual type: [Int]
• In the ‘cStrings’ field of a record
In the expression:
Config {cInts = andCombiner cInts, cStrings = andCombiner cStrings}
In an equation for ‘<>’:
c1 <> c2
= Config
{cInts = andCombiner cInts, cStrings = andCombiner cStrings}
where
andCombiner field = field c1 <> field c2
|
19 | , cStrings = andCombiner cStrings }
| ^^^^^^^^^^^^^^^^^^^^
.../Main.hs:19:34: error:
• Couldn't match type ‘[Char]’ with ‘Int’
Expected type: Config -> [Int]
Actual type: Config -> [String]
• In the first argument of ‘andCombiner’, namely ‘cStrings’
In the ‘cStrings’ field of a record
In the expression:
Config {cInts = andCombiner cInts, cStrings = andCombiner cStrings}
|
19 | , cStrings = andCombiner cStrings }
| ^^^^^^^^
무엇이 컴파일러 오류의 원인이 될 수 있습니까?
'-XNoMonoLocalBinds' *를 끄고'-XNoMonoLocalBinds'를 사용 하시겠습니까? – HTNW
@HTNW 네, 고맙습니다! – Alec