Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Fabio Labella
@SystemFw
I'm assuming that Either is not produced by running side effects, of course
otherwise it should IO(functionThatReturnsYourEither).rethrow
Alexander Samsig
@Asamsig
If I used sequenceU prior to 1.0.1, should I just enable partial unification and change to sequence?
Luka Jacobowitz
@LukaJCB
Yep :+1:
felher
@felher
@SystemFw yeah, great idea, thanks.
Alexander Samsig
@Asamsig
@LukaJCB The behaivior doesn't seem exactly the same, at least I was having trouble getting it to compile. Since the method type definition was contraining to Either[Failure, Seq[Something]], but when I changed it to Either[Failure, List[Something]]it worked. Does this have any effect?
Luka Jacobowitz
@LukaJCB
AFAIK Seq never had any instances, so it should’ve always been List or Vector (:
Alexander Samsig
@Asamsig
I see, so the previous Unapplyimplementation simply accepted it to be upcasted to a Seq?
Luka Jacobowitz
@LukaJCB
I think that may have been what’s happening yes (:
Alexander Samsig
@Asamsig
Okay great, thank you.
Luka Jacobowitz
@LukaJCB
Paulius Imbrasas
@CremboC
Hey guys, are there any built in monad transformers for Option <-> IO? Perhaps anyone has an example?
Andi Miller
@andimiller
what would you expect those to do?
Luka Jacobowitz
@LukaJCB
What’s wrong with OptionT[IO, A]?
Paulius Imbrasas
@CremboC
basically I have some IOs, but some of them return an Option. Depending on the result of the Option, I may have to do another IO
and I'm trying to combine these into a for comprehension in the most readable way
Luka Jacobowitz
@LukaJCB
for {
  a <- OptionT(ioOfOptionOfA)
  b <- OptionT.liftF(someFunctionReturningIO(a))
} yield b
Something like that?
Paulius Imbrasas
@CremboC
yeah, I'll experiment with that and see if it works out. Thanks!
Luka Jacobowitz
@LukaJCB
Sure thing! :sparkles:
Martijn Hoekstra
@martijnhoekstra
Do you have some time for concrete pointers for the BF thing yet @SystemFw
Fabio Labella
@SystemFw
if you read Haskell, this article is a good start https://github.com/quchen/articles/blob/master/write_yourself_a_brainfuck.md
that would be for the "Free" version
your code is not far away
but you are intermingling the parsing and interpretation
if you separate the two
i.e. create an AST for the language, a parser from a string to the AST, and an interpreter from AST to IO or what have you, you'll have done the "Free" one
from there, you can try and convert the AST to its tagless equivalent
Martijn Hoekstra
@martijnhoekstra
I'll give that one a go - that should be almost trivial
felher
@felher
Oh, I just found out there is show"interpolate $something". And it's already catching bugs... :)
Luka Jacobowitz
@LukaJCB
Haha, nice @felher!
Paulius Imbrasas
@CremboC
this is really a stupid question, but why doesn't this work? https://gist.github.com/CremboC/264a1d3a93e6cd0d279504b8eec3883f
Otto Chrons
@ochrons
you're missing one ] before the .empty ;)
Paulius Imbrasas
@CremboC
would be nice if that was the actual problem :/
Fabio Labella
@SystemFw
IO should already have a Monoid fwiw
Luka Jacobowitz
@LukaJCB
Yeah, it’s probably conflicting imports
If you want that kind of behaviour, best newtype it
Paulius Imbrasas
@CremboC
where can I find the instance for Monoid[IO]?
Luka Jacobowitz
@LukaJCB
companion object of IO is my best guess
Paulius Imbrasas
@CremboC
ah yes, thanks
sorry, I'm new to all of this functional programming stuff, trying to understand it
Luka Jacobowitz
@LukaJCB
No worries, if you have any other questions, don’t be afraid to ask!
Paulius Imbrasas
@CremboC
thanks :) I've reduced the number of imports to barebones and it still doesn't seem to work :/ same can't find implicit
Andi Miller
@andimiller
which version of cats-effect are you on?
Paulius Imbrasas
@CremboC
0.5
Andi Miller
@andimiller
works for me with import cats._, cats.implicits._, cats.effect._
@ Monoid[IO[Option[Int]]].empty 
res1: IO[Option[Int]] = IO(None)
Paulius Imbrasas
@CremboC
hmm looks like I have to do import cats.effect._ instead of import cats.effect.IO, i.e. IO is not enough
Fabio Labella
@SystemFw
@CremboC do you have -Ypartial-unification on?
Paulius Imbrasas
@CremboC
yup