I have this code:
drawIdentifiersPanel :: StateT AppState IO ()
drawIdentifiersPanel = do
...
let
drawSel sel = do
appState' <- get
let maybeValues = Map.lookup sel ( appState' ^. #appData . #allIdentifiers )
case maybeValues of
Nothing -> return ()
Just values -> do
let indexedValues = zip [ 0.. ] values
toRun = map ( $ sel ) $ map drawValue indexedValues
( liftIO $ execStateT ( sequence_ toRun ) appState' ) >>= put
maybe ( return () ) drawSel ( appState' ^. #identifierTypeSel )
...
The compiler gives:
horrelate> /home/user/Projects/horrelate/src/IdentifiersPanel.hs:51:5: error:
horrelate> • Non type-variable argument
horrelate> in the constraint: MonadState AppState m
horrelate> (Use FlexibleContexts to permit this)
horrelate> • When checking the inferred type
horrelate> drawSel :: forall (m :: * -> *).
horrelate> (MonadState AppState m, MonadIO m) =>
horrelate> String -> m ()
horrelate> In the expression:
horrelate> do appState <- get
horrelate> liftIO $ Utils.setCursorPos' (appState & cursorPosRef) panelPos
horrelate> liftIO
horrelate> $ newIORef panelSize
horrelate> >>= DearImGui.beginChildOfSize "All Identifiers"
horrelate> let comboActiveStr
horrelate> = fromMaybe "<No identifier type selected>"
horrelate> $ appState ^. #identifierTypeSel
horrelate> ....
horrelate> In an equation for ‘drawIdentifiersPanel’:
horrelate> drawIdentifiersPanel
horrelate> = do appState <- get
horrelate> liftIO $ Utils.setCursorPos' (appState & cursorPosRef) panelPos
horrelate> liftIO
horrelate> $ newIORef panelSize
horrelate> >>= DearImGui.beginChildOfSize "All Identifiers"
horrelate> ....
horrelate> |
horrelate> 51 | drawSel sel = do
horrelate> | ^^^^^^^^^^^^^^^^...
horrelate>
But if I add a type signature:
let
drawSel :: String -> StateT AppState IO ()
drawSel sel = do
It compiles fine. I wonder why is that?