Good afternoon. I am looking for some clarification on monads, please and using bind (at the entrance to composite .), please.
So for this example:
--Monadic parts:
readFile :: String -> IO File
putStr :: String -> IO()
-- Non monadic parts
toMatrix :: String -> CustomMatrix
toString :: CustomMatrix -> String
Essentially, I lazily read the file ( readFile) and then create a custom matrix, converting the matrix to line output. Then come back.
fileReading :: String -> IO
fileReading file = putStr(toString . toMatrix . readFile file)
This is when I start creating a mess using bind >>=to jump from readFile file. Is there a way I can continue to use composites .and bind and compose without making an illegible mess (not my goal).
As always, any help is greatly appreciated. Thanks guys.
source
share