Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Soren
@srnb_gitlab
🤦
Gabriel Volpe
@gvolpe
There's a @tpolecat phrase somewhere in there :smile:
Rob Norris
@tpolecat
There usually is. I am a wellspring of banal observations.
Soren
@srnb_gitlab
The only problem I'm having now is Haskell hates trying to derive MonadTrans (Pipe r) for newtype Pipe r m a = Pipe { runPipe :: SerialT m r -> SerialT m a } but that's not a Cats issue
Fabio Labella
@SystemFw
@srnb_gitlab if you want something that operates on the pipe abstraction, I would recommend against trying to bend streamly into something it is not. Most haskell streaming stuff is built directly with transducers in mind (unlike streamly or fs2), so you could look into pipes or conduit instead. There is a reason why designs that try to unify streaming and concurrency like fs2 or streamly prefer a direct encoding in terms of streams rather than one in terms of stream transducers (pipes)
Soren
@srnb_gitlab
Which one do you recommend? @SystemFw
Fabio Labella
@SystemFw
as for the more general point, have you tried writing that instance manually if haskell can't derive it?
Soren
@srnb_gitlab
Yeah
Fabio Labella
@SystemFw
well, it depends, I haven't used streamly(I have looked at it in some depth though) but it looks nice (but that's because I like fs2 I guess). pipes and conduit are both nice, and if you just need simple streaming I've heard good things about streaming as well
Soren
@srnb_gitlab
I'm thinking about how Lexer m a = Stream m Char -> Stream m a and Parser t m a = Stream m t -> Stream m a, and I want to build streaming operations around that notion
Fabio Labella
@SystemFw
on that MonadTrans instance specifically, take this with a grain of salt because it's just a hunch and I don't have time to investigate, but I smell trouble since SerialT appears in both negative and positive position, and general MonadTrans lift cannot lift that sort of non algebraic operation (and you need more complex machinery)
so streaming parsing?
Soren
@srnb_gitlab
Yeah, I want to have streaming lexing into streaming parsing, and I'm not comfortable with the way megaparsec does it
Fabio Labella
@SystemFw

so streaming parsing?

if that's the case, I'd recommend pipes-parse or streaming, streamly is more for concurrency/control flow things

Soren
@srnb_gitlab
I'll give pipes/pipes-parse a shot
I think the reason I didn't go with pipes initially is because its Producer a m r which is a little weird but I guess that's like fs2's Pull
Fabio Labella
@SystemFw
generally libraries in the pipes ecosystem have a beautiful Tutorial module that you can read on hackage
yeah, most streaming abstraction in haskell have a monad instance on the returned value, rather than the emitted one
which is great for pure streaming
for control flow, a monad instance on the emitted value is much more convenient: this is what streamly has, but then streamly suffers in the other use case
one under appreciated design decision of fs2 is to separate the two into Stream and Pull (which are related to each other ofc)
where Pull is a monad in the returned type, and can be used for stateful streaming, and Stream is a monad in the emitted type, and can be used for control flow
and conceptually Stream f a = Pull f a ()
when I started with fs2 the existence of both Stream and Pull seemed like a wart (although at the time it was obscured by a bunch of other stuff like Handle), but in truth it's one of the best design decisions of the whole library
Adam Rosien
@arosien
i still don't know anything about Pull. where to start?
Fabio Labella
@SystemFw
my writings have a bunch of long-ish explanations (for lack of a more structured resource, sorry) http://systemfw.org/writings
the tl;dr is that it's a fancy iterator, just built as an algebra rather than side-effecty interface
Adam Rosien
@arosien
thanks
oh, that's interesting, i didn't realize that a lot of the links point back to gitter. great idea!
I also wrote up a thing about Pull
that I think helps drive home the "iterator" aspect
Fabio Labella
@SystemFw

oh, that's interesting, i didn't realize that a lot of the links point back to gitter. great idea!

Eventually I will have to go and do a backup somewhere else, but I dread that time

Adam Rosien
@arosien
ThreadApp, please unroll (this gitter link)
Gavin Bisesi
@Daenyth
fabio needs to hire a gitter assistant to take his conversations and translate to blogs :)
Fabio Labella
@SystemFw
tbh for some things I quite like the conversational format (although others would be better served by a proper exposition)
I worry more about gitter getting shutdown at brief notice
Gavin Bisesi
@Daenyth
I learn and internalize the things I teach better, in conversation, than trying to lecture
At least gitter is indexed on google
Some option to grab archives from there
Fabio Labella
@SystemFw
oh yeah still miles better than the proposed alternatives (which is why I opposed migrating to Discord or Slack)
Nathaniel Fischer
@kag0
https://typelevel.org/cats/datatypes/either.html#solution-2-adts-all-the-way-down talks about error ADTs, what's SOP for common errors that you want to share across modules?
Nick Telford
@nicktelford
Is there anything stopping cats from defining typeclass instances for SeqMap? It's useful for preserving the ordering of the mapping.
Jasper Moeys
@Jasper-M
Is there some well known name for this method foo?
def foo[A, B, C](f: A => B)(g: (A, B) => C): A => C =
  a => g(a, f(a))
Fabio Labella
@SystemFw
@Jasper-M that seems equivalent of Applicative.ap for F = A =>, with uncurrying and tuple == parameter lists
but it's not worth writing it differently than what you have I don't think
you can notice by changing (A, B) => C into A => B => C
then factorising the whole signature into (A => B) => (A => (B => C)) => (A => C)
then abstracting A => into F[_]
F[B] => F[B => C] => F[C]