Es ist nur ein Skelett des Programms. Ich habe Hauptfunktion, dassVerwenden von State.modify aus einer anderen Funktion
State [Dec] [Dec]
mainCon = do
acc <- get
put []
modify $ (++) [some func]
return acc
Auf einer Stufe I Funktion aufrufen:
foldlWithKey'
(\list' key' val' ->
if (...)
then
(Control.Monad.State.modify $ (Prelude.++) [elem]) >>
some code
: list')
else
(Control.Monad.State.modify $ (Prelude.++) []) >>
some code
: list')
)
[]
(map')
und wollen Staat in mainCon ändern, aber weiterhin Traverse Karte‘. Der Fehler lautet:
No instance for (MonadState [Dec] [])
arising from a use of ‘Control.Monad.State.modify’
In the expression: Control.Monad.State.modify
[Dezember] von Vorlage Haskell. Wie kann ich dieses Problem einfach lösen?
Was ist die Typ-Signatur von 'foldWithKey''? – ErikR
@ErikR foldlWithKey ':: (a -> k -> v -> a) -> a -> HashMap k v -> a – Ivan