Re: [scalaz] monadic logging alongside I/O -- OptionT[WriterT[scalaz.Id.Id, List[String], A]

90 views
Skip to first unread message

Ben Kolera

unread,
May 18, 2013, 10:09:45 PM5/18/13
to sca...@googlegroups.com
Dustin,

Try adding:

import syntax.monadPlus._

That'll bring in the filter syntax for you.

Or alternatively, take the type annotations off of your for comprehensions as they are forcing a pattern match that the scala compiler isn't smart enough to optimise out.


On a side note: I'd say that EitherT is a better monad for you than OptionT in this case so you can log the error when you 500. Take a look at EitherT.fromTryCatch [1]. :)


Cheers,
Ben

[1] https://github.com/scalaz/scalaz/blob/scalaz-seven/core/src/main/scala/scalaz/EitherT.scala#L215


On Sunday, 19 May 2013 at 8:52 AM, Dustin Getz wrote:

> Experimenting with a monadic logger for logging database queries and results. Here is a complete gist that sequences two SQL queries (that could fail) inside a logger. https://gist.github.com/dustingetz/5605972
>
> One error on L25, when the comprehension is actually executed:
>
> [error] value filter is not a member of scalaz.OptionT[MyLogger, Map[String, Skill]][error] allSkills: Map[String, Skill] <- SkillsMapping.all(dbconn)
>
> sooo close!!!
>
> Scala 2.10, Scalaz 7.0.0, Play 2.1
>
> --
> You received this message because you are subscribed to the Google Groups "scalaz" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to scalaz+un...@googlegroups.com (mailto:scalaz+un...@googlegroups.com).
> To post to this group, send email to sca...@googlegroups.com (mailto:sca...@googlegroups.com).
> Visit this group at http://groups.google.com/group/scalaz?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



Reply all
Reply to author
Forward
0 new messages