Haskell Recursive function over IO list?

ExtractPatternStrings ∷ IO (Map String SqlValue) → IO String An IO String is an IO action that produces a String result. Your use of do notation ensures extractPatternStrings produces an IO String not a String An IO (Map String SqlValue) is an IO action that produces a Map String SqlValue result. But you cannot pattern match against an IO action.

The syntax you use is for matching directly against a list, not against an IO action that produces a list You should use this type signature instead: extractPatternStrings ∷ Map String SqlValue → IO String Except that, as @missingno points out, this doesn't need to be an IO action: extractPatternStrings ∷ Map String SqlValue → String extractPatternStrings = extractPatternStrings (m:ms) = toString m : extractPatternStrings ms where toString ∷ Map String SqlValue → String toString m = (fromSql . FromJust . (Map.

Lookup "word"))∷ String Or, better (and fixing an error in toString ): extractPatternStrings ∷ Map String SqlValue → String extractPatternStrings = map toString where toString ∷ Map String SqlValue → String toString = fromSql . FromJust . Map.

Lookup "word More succinctly: extractPatternStrings ∷ Map String SqlValue → String extractPatternStrings = map (fromSql . FromJust . Map.

Lookup "word") If you really must have the original signature, then use liftM either by changing your calling code to selectAll ↠liftM extractPatternStrings (and I must confess I don't recognise the operator you use there), or by defining extractPatternStrings as extractPatternStrings ∷ IO Map String SqlValue → IO String extractPatternStrings = liftM $ map (fromSql . FromJust . Map.

Lookup "word") But I recommend the former.

ExtractPatternStrings ∷ IO (Map String SqlValue) → IO String An IO String is an IO action that produces a String result. Your use of do notation ensures extractPatternStrings produces an IO String, not a String. An IO (Map String SqlValue) is an IO action that produces a Map String SqlValue result.

But you cannot pattern match against an IO action. The syntax you use is for matching directly against a list, not against an IO action that produces a list. You should use this type signature instead: extractPatternStrings ∷ Map String SqlValue → IO String Except that, as @missingno points out, this doesn't need to be an IO action: extractPatternStrings ∷ Map String SqlValue → String extractPatternStrings = extractPatternStrings (m:ms) = toString m : extractPatternStrings ms where toString ∷ Map String SqlValue → String toString m = (fromSql .

FromJust . (Map. Lookup "word"))∷ String Or, better (and fixing an error in toString): extractPatternStrings ∷ Map String SqlValue → String extractPatternStrings = map toString where toString ∷ Map String SqlValue → String toString = fromSql .

FromJust . Map. Lookup "word" More succinctly: extractPatternStrings ∷ Map String SqlValue → String extractPatternStrings = map (fromSql .

FromJust . Map. Lookup "word") If you really must have the original signature, then use liftM, either by changing your calling code to selectAll ↠liftM extractPatternStrings (and I must confess I don't recognise the operator you use there), or by defining extractPatternStrings as extractPatternStrings ∷ IO Map String SqlValue → IO String extractPatternStrings = liftM $ map (fromSql .

FromJust . Map. Lookup "word") But I recommend the former.

I managed to get it working with the former. Thanks for your help! Oh and that operator was the >>=.

My editor just converts that to the unicode symbol. – providence Oct 18 at 20:14.

The return wraps your return value in IO, so that takes care of the return type IO String. However it doesn't help you with your argument type, which is (Map String SqlValue), but which you're trying to pattern match against the empty list. Basically you can't pattern match against IO values.So you should either get rid of the IOs (which do seem wholly unnecessary in your code) or if you really do want the function to take an IO (though I can't imagine why you would), you have to unwrap your argument before you can pattern match against it, which would look like this: extractPatternStrings lstIO = do lst ... (m:ms) -> ...

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions