Haskell UI do clause how to print?

This is the next question. I am using a graphics library in Haskell called Threepenny-GUI . In this library, the main function returns a UI monad object. I am trying to execute a simple print command without success. What is the correct operation to enable printing for debugging purposes.

code:

 main :: IO () main = startGUI defaultConfig setup setup :: Window -> UI () setup w = do print "debug message 1 " 

Error:

 Couldn't match type 'IO' with 'UI' Expected type: UI () Actual type: IO () In a stmt of a 'do' block: print "labels and values " 
+2
source share
1 answer

Based on types, this is a good use of liftIO . liftIO is of type MonadIO m => IO a -> ma , so it can be used as follows:

 liftIO (print "debug message 1") 

The type of this expression may be UI () , since the UI is an instance of MonadIO , and print "debug message 1" is of type IO () .

+5
source

Source: https://habr.com/ru/post/989528/


All Articles