1
import Text.JSON
import Control.Monad
data Status = Status { user :: String, text :: String } deriving Show
makeStatus :: JSObject JSValue -> Result Status
makeStatus tweet = let (!) = flip valFromObj in do
userObject <- tweet ! "user"
user <- userObject ! "screen_name"
text <- tweet ! "text"
return Status {user = user, text = text}
[1 of 1] Compiling Main (twitter.hs, interpreted)
twitter.hs:11:27:
Couldn't match expected type `[Char]'
with actual type `JSObject JSValue'
Expected type: String
Actual type: JSObject JSValue
In the `user' field of a record
In the first argument of `return', namely
`Status {user = user, text = text}'
Failed, modules loaded: none.
이 let (!) = flip valFromObj in
를 제거하고 valFromObj "user" tweet
등으로 tweet ! "user"
을 대체 오류를 발생, 모든 것이 괜찮습니다. (!)
유형 발생할 일에하게 표현