liftIO $ BinLog.getLastBinLogTracker conn >>= \ case
The whole computation to the right of liftIO needs to be IO, meaning
BinLog.getLastBinLogTracker conn >>= \ case
Just tracker -> do
es <- BinLog.decodeRowBinLogEvent =<< BinLog.dumpBinLog conn 1024 tracker False
forever $ do
Streams.read es >>= \ case
Just (BinLog.RowWriteEvent _timestamp _tracker table events) ->
insertEvents [] -- events
Nothing -> return ()
Nothing -> error "can't get latest binlog position"
This is supposed to be in IO, but insertEvents is in App, and you are searching for a way to lower it into IO. Instead of that, try to lift the other IO parts to App using liftIO! Like this (I think, if it doesn’t quite work try to massage it a bit, I haven’t run the code ):
liftIO (BinLog.getLastBinLogTracker conn) >>= \ case
Just tracker -> do
es <- liftIO $ BinLog.decodeRowBinLogEvent =<< BinLog.dumpBinLog conn 1024 tracker False
forever $ do
liftIO (Streams.read es) >>= \ case
Just (BinLog.RowWriteEvent _timestamp _tracker table events) ->
insertEvents [] -- events
Nothing -> return ()
Nothing -> error "can't get latest binlog position"