do
fieldA.fieldB1.fieldX1 .= "xxx"
fieldA.fieldB2.fieldY1 .= "yyy"
fieldA.fieldB3.fieldz1 %= fun "zzz"
Нормально
basefun smth = do
let fun = ...
value <- use (fieldA.fieldB3.fieldz1)
let value2 = ...
case funFromPrelude value2 of
aaa -> ...
bbb ->
fieldA.fieldB1.fieldX1 .= "xxx"
Нормально
basefun smth = do
let fun = ...
value <- use (fieldA.fieldB3.fieldz1)
let value2 = ...
case funFromPrelude value2 of
aaa -> ...
bbb ->
fieldA.fieldB1.fieldX1 .= "xxx"
fieldA.fieldB2.fieldY1 .= "yyy"
Precedence parsing error
cannot mix ‘.=’ [infix 4] and ‘%=’ [infix 4] in the same
infix expression (typecheck)
basefun smth = do
let fun = ...
value <- use (fieldA.fieldB3.fieldz1)
let value2 = ...
case funFromPrelude value2 of
aaa -> ...
bbb -> do
fieldA.fieldB1.fieldX1 .= "xxx"
fieldA.fieldB2.fieldY1 .= "yyy"
Нормально
basefun smth = do
let fun = ...
value <- use (fieldA.fieldB3.fieldz1)
let value2 = ...
case funFromPrelude value2 of
aaa -> ...
bbb -> do
fieldA.fieldB1.fieldX1 .= "xxx"
fieldA.fieldB2.fieldY1 .= "yyy"
fieldA.fieldB3.fieldz1 %= fun "zzz"
Не матча в fieldA.fieldB3.fieldz1 %= fun "zzz"
• Couldn't match expected type: a
-> a
with actual type: a
bbb -> — Тут пропущен "ду" fieldA.fieldB1.fieldX1 .= "xxx" fieldA.fieldB2.fieldY1 .= "yyy"
там есть вариант с do
так вариант с ду и работает
Без ду оно это парсит как ... .= ("foo" ...) %= ... В последнем случае у fun "zzz" тип не тот. Влепи вместо fun "zzz" скажем _ и посмотри, что GHC скажет
Обсуждают сегодня