Comments (4)
@ggranberry try this!
(False, m) -> do
anEither <- say m config
case anEither of
Left e -> putStrLn ("an error occurred! " <> show e)
Right _ -> return ""
The problem here is that typeclasses generate bad errors :(
You should think of say
as having type IO (Either RequestError ())
, which uses the typeclass instance MonadError e (Either e)
. The reason the very generic mtl type exists is that you can use it in deeper monad stacks where perhaps there are more layers between the IO
and the Either RequestError
.
Your code is forcing GHC to infer say m config
as IO a
. Now IO does have a MonadError
instance, except it's MonadError IOException
-- the weird mismatch between IOException
and RequestError
is what's causing the problem here.
Hope that makes sense. Keep me updated! Thanks for using the library.
from linklater.
@hlian Thanks for the quick and detailed reply! Your comment was incredibly helpful and I'm mostly seeing why it is breaking right now. Though some of the some of the mtl type stuff was a bit above me as this is my first attempt at a small Haskell project.
I went ahead and tried to implement your suggestion and got the same error as before with a few extra ones added. It looks like say isn't being evaluated as IO (Either RequestError ())
from what I'm seeing.
/Users/ranberry/haskell/scraper/src/Notification/SlackBot.hs:38:19: error:
• Couldn't match type ‘IOException’
with ‘Network.Linklater.Types.RequestError’
arising from a functional dependency between:
constraint ‘mtl-2.2.1:Control.Monad.Error.Class.MonadError
Network.Linklater.Types.RequestError IO’
arising from a use of ‘say’
instance ‘mtl-2.2.1:Control.Monad.Error.Class.MonadError
IOException IO’
at <no location info>
• In a stmt of a 'do' block: anEither <- say m config
In the expression:
do { anEither <- say m config;
case anEither of {
Left e -> putStrLn ("an error occurred! " <> show e)
Right _ -> return "" } }
In a case alternative:
(False, m)
-> do { anEither <- say m config;
case anEither of {
Left e -> putStrLn ("an error occurred! " <> show e)
Right _ -> return "" } }
/Users/ranberry/haskell/scraper/src/Notification/SlackBot.hs:40:9: error:
• Couldn't match expected type ‘()’ with actual type ‘Either a0 t0’
• In the pattern: Left e
In a case alternative:
Left e -> putStrLn ("an error occurred! " <> show e)
In a stmt of a 'do' block:
case anEither of {
Left e -> putStrLn ("an error occurred! " <> show e)
Right _ -> return "" }
/Users/ranberry/haskell/scraper/src/Notification/SlackBot.hs:40:19: error:
• Couldn't match type ‘()’ with ‘T.Text’
Expected type: IO T.Text
Actual type: IO ()
• In the expression: putStrLn ("an error occurred! " <> show e)
In a case alternative:
Left e -> putStrLn ("an error occurred! " <> show e)
In a stmt of a 'do' block:
case anEither of {
Left e -> putStrLn ("an error occurred! " <> show e)
Right _ -> return "" }
/Users/ranberry/haskell/scraper/src/Notification/SlackBot.hs:41:9: error:
• Couldn't match expected type ‘()’ with actual type ‘Either t1 t2’
• In the pattern: Right _
In a case alternative: Right _ -> return ""
In a stmt of a 'do' block:
case anEither of {
Left e -> putStrLn ("an error occurred! " <> show e)
Right _ -> return "" }```
from linklater.
@ggranberry silly me! i was missing a runExceptT
call. i updated JPEGbot to illustrate the solution:
from linklater.
@hlian That did the trick, thanks!!
from linklater.
Related Issues (10)
- Nobody's created any issues :( HOT 1
- Specify GET for your slack integration method HOT 2
- Remove upper constraint on base version HOT 2
- issues installing linklater HOT 4
- Versioning discrepancy? HOT 4
- Couldn't match type `IOException` with `RequestError` HOT 1
- Variable not in scope: checkResponse HOT 1
- Add comparison with 'slack-api' library HOT 1
- Network.Socket.recvBuf: failed on examples
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linklater.