Given the following declarations
data MyCustomString = MyCustomString String deriving (Show, Eq)
getSomeString :: IO String
I'd like to process the output of getSomeString into a IO MyCustomString in a do context:
do
cs_one <- getSomeString
cs_two <- getSomeString
-- at this point, `cs_one` and `cs_two` are of type `String`
-- how to construct them into `MyCustomString` instead with no additional lines?
However, getSomeString returns an String and not an MyCustomString. How could I use the MyCustomString constructor so that both cs_one and cs_two are, at this point in the code, of type MyCustomString ?
I've tried this to no avail:
-- this does not work
do
MyCustomString cs_one <- getSomeString
MyCustomString cs_two <- getSomeString
-- this neither
do
cs_one <- MyCustomString getSomeString
cs_two <- MyCustomString getSomeString