Skip to content

Instantly share code, notes, and snippets.

@robotmay
Created November 28, 2019 18:36
Show Gist options
  • Save robotmay/96cd7c8f9bf71500fecea85eede26000 to your computer and use it in GitHub Desktop.
Save robotmay/96cd7c8f9bf71500fecea85eede26000 to your computer and use it in GitHub Desktop.
src/Main.hs:79:21: error:
• Couldn't match type ‘Text’ with ‘[Char]’
Expected type: String
Actual type: Text
• In the second argument of ‘parse’, namely
‘(Text.Encoding.decodeUtf8 b)’
In the expression: parse pLog (Text.Encoding.decodeUtf8 b)
In an equation for ‘log’:
log = parse pLog (Text.Encoding.decodeUtf8 b)
|
79 | parse pLog (Text.Encoding.decodeUtf8 b)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
src/Main.hs:116:10: error:
• Couldn't match expected type ‘Text’ with actual type ‘[Char]’
• In the ‘time’ field of a record
In the first argument of ‘return’, namely ‘Log {..}’
In a stmt of a 'do' block: return Log {..}
|
116 | return Log {..}
| ^^^^^^^^
app :: SpockM () TwcaSession TwcaAppState ()
app = do
get root rootAction
post "ingest" $ body >>= \b ->
let
checker user pass =
Monad.unless (user == "test" && pass == "test") $ do
setStatus Http.status401 >> text "Unauthorised"
log =
parse pLog (Text.Encoding.decodeUtf8 b)
in requireBasicAuth "Ingest" checker $ \() -> do
setStatus Http.status200 >> text ""
data Log = Log
{ size :: Int
, time :: Text
, message :: Text
} deriving (Eq, Show)
pLog :: Parser Log
pLog = do
size <- L.decimal
void (char ' ')
void (char '<')
void (some alphaNumChar)
void (char '>')
void alphaNumChar
void (char ' ')
time <- (some alphaNumChar)
void (char ' ')
message <- (some alphaNumChar)
return Log {..}
83 <40>1 2012-11-30T06:45:29+00:00 host app web.3 - State changed from starting to up
119 <40>1 2012-11-30T06:45:26+00:00 host app web.3 - Starting process with command `bundle exec rackup config.ru -p 24405`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment