Created
July 26, 2012 19:08
-
-
Save schovi/3183859 to your computer and use it in GitHub Desktop.
How to use 'read' in haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
processDbRequest :: Connection -> [String] -> String | |
processDbRequest conn record@(tableId:requestType:_:rawParams) = | |
let params = extractParams rawParams | |
tableId = read tableId | |
recordId = read (params M.! 1) | |
in case tableId of | |
1 -> "yes" | |
_ -> "oh no" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
test.hs:7:10:
No instance for (Num String)
arising from the literal `1'
Possible fix: add an instance declaration for (Num String)
In the pattern: 1
In a case alternative: 1 -> "yes"
In the expression:
case tableId of {
1 -> "yes"
_ -> "oh no" }