MonadThrow and Either instance

Hello, I try to parse a config file and extract a (Path Abs Dir) from these files So I have a parser as defined in config-ini So I need a function with this signature pathAbsDir :: Text -> Either String (Path Abs Dir) pathAbsDir t = do d <- try $ parseAbsDir (unpack . uncomment $ t) case d of Right v -> Right v Left e -> Left (show e) since I am using parseAbsDir wi this signature parseAbsDir :: MonadThrow m => FilePath -> m (Path Abs Dir) I would like to know how to write the patAbsDir method for now I have this error message src/Hkl/Binoculars/Config.hs:82:8-49: error: • Couldn't match type ‘[Char]’ with ‘GHC.Exception.SomeException’ arising from a use of ‘try’ • In a stmt of a 'do' block: d <- try $ parseAbsDir (unpack . uncomment $ t) In the expression: do d <- try $ parseAbsDir (unpack . uncomment $ t) case d of Right v -> Right v Left e -> Left (show e) In an equation for ‘pathAbsDir’: pathAbsDir t = do d <- try $ parseAbsDir (unpack . uncomment $ t) case d of Right v -> Right v Left e -> Left (show e) | 82 | d <- try $ parseAbsDir (unpack . uncomment $ t) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I understand that the MonadThrow instance of Either is for Either Exception a But I want (Either String a). Cheers Frederic

Okay, this is a small series of polls being unscientifically conducted by an individual user on Mastodon for fun, but still, Haskell is currently being ground into the dirt by Bash scripting, and I may lose all of my faith in humanity: https://mastodon.social/@fribbledom/103610609652779434

This being as you say, a series of polls unscientifically conducted, is
surely a success worthy enough to be avoided?
On Fri, Feb 7, 2020 at 5:31 AM Irfon-Kim Ahmad
Okay, this is a small series of polls being unscientifically conducted by an individual user on Mastodon for fun, but still, Haskell is currently being ground into the dirt by Bash scripting, and I may lose all of my faith in humanity:
https://mastodon.social/@fribbledom/103610609652779434
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- -- Kim-Ee

Hey,
No matter what I do, the Vot button on that post is inactive, and,
therefore, I can't vote. I tried to register & (even!) follow the author of
the poll.
--
Best, Artem
On Thu, 6 Feb 2020 at 17:31, Irfon-Kim Ahmad
Okay, this is a small series of polls being unscientifically conducted by an individual user on Mastodon for fun, but still, Haskell is currently being ground into the dirt by Bash scripting, and I may lose all of my faith in humanity:
https://mastodon.social/@fribbledom/103610609652779434
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

World Championships? I thought Haskell was #1 in the Galaxy.
Galactic Language #1.
On Thu, 6 Feb 2020 at 18:17, Artem Pelenitsyn
Hey,
No matter what I do, the Vot button on that post is inactive, and, therefore, I can't vote. I tried to register & (even!) follow the author of the poll.
-- Best, Artem
On Thu, 6 Feb 2020 at 17:31, Irfon-Kim Ahmad
wrote: Okay, this is a small series of polls being unscientifically conducted by an individual user on Mastodon for fun, but still, Haskell is currently being ground into the dirt by Bash scripting, and I may lose all of my faith in humanity:
https://mastodon.social/@fribbledom/103610609652779434
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

The fact that PHP is not only still a thing, but actually enjoys massive
popularity, should be enough to destroy any and all faith in humanity
already. You don't need unscientific surveys to help with that.
On Fri, Feb 7, 2020, 00:31 Krystal Maughan
World Championships? I thought Haskell was #1 in the Galaxy. Galactic Language #1.
On Thu, 6 Feb 2020 at 18:17, Artem Pelenitsyn
wrote: Hey,
No matter what I do, the Vot button on that post is inactive, and, therefore, I can't vote. I tried to register & (even!) follow the author of the poll.
-- Best, Artem
On Thu, 6 Feb 2020 at 17:31, Irfon-Kim Ahmad
wrote: Okay, this is a small series of polls being unscientifically conducted by an individual user on Mastodon for fun, but still, Haskell is currently being ground into the dirt by Bash scripting, and I may lose all of my faith in humanity:
https://mastodon.social/@fribbledom/103610609652779434
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On Thu, Feb 06, 2020 at 03:30:15PM +0000, PICCA Frederic-Emmanuel wrote:
So I need a function with this signature
pathAbsDir :: Text -> Either String (Path Abs Dir) pathAbsDir t = do d <- try $ parseAbsDir (unpack . uncomment $ t) case d of Right v -> Right v Left e -> Left (show e)
since I am using parseAbsDir wi this signature
parseAbsDir :: MonadThrow m => FilePath -> m (Path Abs Dir)
I would like to know how to write the patAbsDir method
Try (no pun intended): import Control.Monad.Catch.Pure (runCatch) import Data.Text (Text, unpack) import Path (Path, Abs, Dir, parseAbsDir) pathAbsDir :: Text -> Either String (Path Abs Dir) pathAbsDir t = do let d = runCatch $ parseAbsDir (unpack t) case d of Right v -> Right v Left e -> Left $ show e -- Viktor.

Thans a lot Viktor, it works I did not know about runCatch. I should try these kind of runXXX on hoogle. have a nice day Frederic

On Feb 7, 2020, at 1:19 AM, PICCA Frederic-Emmanuel
wrote: I did not know about runCatch. I should try these kind of runXXX on hoogle.
FWIW, I did not find it on Hoogle. Rather I looked at the documentation of MonadCatch, noting the only instance that wrapped a generic Monad that didn't already have MonadCatch was 'CatchT m a'. That led naturally to 'Catch = CatchT identity' and 'runCatch'. Finding it through ad-hoc searches would have been much harder... -- Viktor.
participants (7)
-
Artem Pelenitsyn
-
Irfon-Kim Ahmad
-
Kim-Ee Yeoh
-
Krystal Maughan
-
PICCA Frederic-Emmanuel
-
Tobias Dammers
-
Viktor Dukhovni