These are chat archives for typelevel/general

14th
Jul 2017
Edmund Noble
@edmundnoble
Jul 14 2017 00:08
@andyscott What do you think of adding something like "type class products" to iota? Do you think perhaps providing higher-kinded products + coproducts is slightly out of scope?
Something that would be able to generically take the role of @module decls in freestyle
andy scott
@andyscott
Jul 14 2017 16:07
How much higher kinded?
@peterneyens did a side branch with coproducts for T[_, _[_], _[_], _]— my plan was to get it incorperated. And to more easily allow for any kind of kindness with as little boiler plate/additional work as possible.
Edmund Noble
@edmundnoble
Jul 14 2017 16:47
I'm talking products of F[_] and G[_], both applied to A
In two usecases: implicitly and otherwise, as an ordinary value (like cats.data.Prod)
Like an implicit IProd[Monoid :: PNil, A] should let me resolve a Monoid[A]
andy scott
@andyscott
Jul 14 2017 16:49
Oh I see
Edmund Noble
@edmundnoble
Jul 14 2017 16:51
The most important part (to me) is constructs like IProd[Monoid :: Id :: PNil, _], basically "existentialized type classes"
andy scott
@andyscott
Jul 14 2017 16:51
I’ve been looking at something related, actually. I’ve been wanting to ask for implicit evidence for hetergenous lists of types for a while. “I need evicdence of F[_] for each of L"
What you’re asking for is I need “each of L[_] for A”?
Edmund Noble
@edmundnoble
Jul 14 2017 16:53
Exactly
andy scott
@andyscott
Jul 14 2017 16:53
Seems reasonable to add to Iota
Edmund Noble
@edmundnoble
Jul 14 2017 16:53
It's more "heterogeneous lists of implicit evidence" than it is "implicit evidence for heterogeneous lists", I think (unless you use it with KList)
Alright, I'll make a PR :)
andy scott
@andyscott
Jul 14 2017 16:53
:)
I hope you like working with macros and untyped optimizations
Edmund Noble
@edmundnoble
Jul 14 2017 16:55
LOL hell yes
Oh wow I didn't know you had Prod already that makes this make a lot of sense
ProdK it is, then
andy scott
@andyscott
Jul 14 2017 16:57
I needed it for my preliminary generic derivation work
I have a lot of playground branches locally, where I experiment with all kinds of “fun” things
Edmund Noble
@edmundnoble
Jul 14 2017 18:01
Thanks for the warning but your macros look :100: :moneybag: :dollar: :P
andy scott
@andyscott
Jul 14 2017 18:06
Sure thing. And thanks! :)
Jacob Barber
@Jacoby6000
Jul 14 2017 18:37
At my office, we've started using protobuf and the java implementations leave much to be desired... Could I use Free and all that to pretty up the interface a bit? Are there any examples of taking traditional java apis and making them better using some functional patterns? I know doobie is one example, but I'd like to see others as well
Edmund Noble
@edmundnoble
Jul 14 2017 18:40
How about this:
Just remove the builders
And the writeTo crap
In exchange for type classes
In doing so you make the protobuf serialization an extra layer you can add on top of your model using the type classes, instead of generating the classes themselves and creating yet another model to separate concerns
Jacob Barber
@Jacoby6000
Jul 14 2017 18:43
Sorry, I shouldn't have said protobuf... We're using gRPC which happens to use protobuf
the main problem is the GRPC abstractions
I tend to conflate the two, since this is the only context I've ever used protobuf in
Edmund Noble
@edmundnoble
Jul 14 2017 18:45
It looks like gRPC is an enterprise-plus version of autowire with streaming, and mutability everywhere
(though that's the Java API)
If the only thing that makes it gRPC is the messages sent back and forth, you could make a significantly better version of this API with fs2 and http4s
Jacob Barber
@Jacoby6000
Jul 14 2017 18:50
@edmundnoble I've been wanting to rewrite it, ever since I saw how you have to implement these things
Also @tpolecat I couldn't agree more
Could http4s handle the streaming parts? or is that where fs2 comes in?
Edmund Noble
@edmundnoble
Jul 14 2017 18:51
TBH the alternative he posts looks 1000x nicer from an FP perspective
fs2 does the streaming, http4s is based on fs2
Well, "provides" more than does I suppose
Jacob Barber
@Jacoby6000
Jul 14 2017 18:51
The alternative who posts?
Edmund Noble
@edmundnoble
Jul 14 2017 18:52
Runar
Oh wow I didn't even realize the problem with protobuf
Google is taking away my goddamn generics again
Jacob Barber
@Jacoby6000
Jul 14 2017 18:53
Ah... Well, unfortunately it doesn't matter how nice it looks. The business has made its decision and one guy here just got done tearing out all of our old http REST stuff for grpc
Edmund Noble
@edmundnoble
Jul 14 2017 18:53
Despite looking nice I don't know if it's even ready for prod, regardless
Jacob Barber
@Jacoby6000
Jul 14 2017 18:53
@edmundnoble yup... I've got 8 message types representing the same structure that has a single difference in field type
Edmund Noble
@edmundnoble
Jul 14 2017 18:54
Ugh fucking Google
andy scott
@andyscott
Jul 14 2017 18:54
protobuf has been the on-and-off bane of my existance this past year :frowning:
Jacob Barber
@Jacoby6000
Jul 14 2017 18:55
Sounds like my next project will be writing an fp implementation of grpc ;)
Edmund Noble
@edmundnoble
Jul 14 2017 18:55
But do it stream
Jacob Barber
@Jacoby6000
Jul 14 2017 18:55
Maybe I can also force the users of the lib to standardize on output headers and error handling. gRPC literally has zero conventions
Edmund Noble
@edmundnoble
Jul 14 2017 18:57
Do a version of protobuf but with polymorphism and refinement types and build a better gRPC on it
Jacob Barber
@Jacoby6000
Jul 14 2017 18:57
@andyscott that might be useful for me, but I'm not sure... I can't tell if it's made to replace grpc libs or an alternative to grpc in general
Edmund Noble
@edmundnoble
Jul 14 2017 18:57
Afaik this is gRPC
import io.grpc.{CallOptions, ClientCall, MethodDescriptor}
(from the code)
andy scott
@andyscott
Jul 14 2017 18:58
Freestyle RPC is iniially gRPC, and we plan to make it scala focused. But long term it may abstract over other backends.
Jacob Barber
@Jacoby6000
Jul 14 2017 18:58
Well, I saw that. But I wasn't sure where it was supposed to sit in the ecosystem
Edmund Noble
@edmundnoble
Jul 14 2017 18:58
Hopefully it also abstracts over the wire protocol ;)
Jacob Barber
@Jacoby6000
Jul 14 2017 18:58
lol
Rob Norris
@tpolecat
Jul 14 2017 18:58
Frestyle has RPC now?
andy scott
@andyscott
Jul 14 2017 18:58
WIP, yes
We better finish it because I’m supposed to demo it in November :joy: :joy:
Jacob Barber
@Jacoby6000
Jul 14 2017 18:59
@edmundnoble coming up with something better than protobuf isn't hard... What's hard is getting the adoption and library support that it has :/
andy scott
@andyscott
Jul 14 2017 18:59
Aye
Edmund Noble
@edmundnoble
Jul 14 2017 19:00
@Jacoby6000 The issue from my perspective is that most libraries do not abstract over wire protocol
Jacob Barber
@Jacoby6000
Jul 14 2017 19:00
I should do it the Go way. Make a bunch of code generation preprocessors for implementing generics
Edmund Noble
@edmundnoble
Jul 14 2017 19:00
You mean Python scripts?
Rob Norris
@tpolecat
Jul 14 2017 19:00
Just in terms of branding you might consider not saying Freestyle-X and Freestyle-Y because it looks more and more like a framework. See Akka-X and Akka-Y.
Jacob Barber
@Jacoby6000
Jul 14 2017 19:00
yeah :p
Rob Norris
@tpolecat
Jul 14 2017 19:00
Or JBoss.
tpolecat @tpolecat anhks himself
andy scott
@andyscott
Jul 14 2017 19:01
@tpolecat I have been suggesting that we have freestyle-x and freestyle-y, but freestyle-x may use the unbranded super-x-galore lib that we also build in a more general fashion.
Edmund Noble
@edmundnoble
Jul 14 2017 19:01
Tbh I thought you had "freestyle" and then you had "frees"
Frees being the whole toolset and freestyle giving the macros and stuff
Jacob Barber
@Jacoby6000
Jul 14 2017 19:01
I wish that freestyle project was a bit more mature. I'd push to get us to use that til i was blue in the face
Edmund Noble
@edmundnoble
Jul 14 2017 19:02
Use tagless you'll blow their minds
You have to get off Future first ;)
Jacob Barber
@Jacoby6000
Jul 14 2017 19:02
I did a presentation using the tagless pattern last night :p
Edmund Noble
@edmundnoble
Jul 14 2017 19:02
Ayyyy why not just push to use that?
Jacob Barber
@Jacoby6000
Jul 14 2017 19:02
didn't even know it was the tagless pattern til one of the guys told me
Any sufficiently useful thing I come up with has already been invented by somebody else
just like that one guy says
Edmund Noble
@edmundnoble
Jul 14 2017 19:03
You are far from alone there, I saw three final tagless talks at Typelevel summit NYC
I was the only one who knew the name
But the idea behind it is dead simple
Especially from Java
Jacob Barber
@Jacoby6000
Jul 14 2017 19:03
I just remember seeing the onion pattern using GADTs and Free interpreters, and was like... How could I make this less intimidating for people who aren't super FP oriented
andy scott
@andyscott
Jul 14 2017 19:03
Guilty: I had been doing tagless accidentally before I knew it was tagless
Jacob Barber
@Jacoby6000
Jul 14 2017 19:03
tagless is the obvious answer
andy scott
@andyscott
Jul 14 2017 19:04
I wanted to do free, but I didn’t want to force others using my API to use free.
Edmund Noble
@edmundnoble
Jul 14 2017 19:04
Tagless actually brings an incredible amount of benefits even beyond understandability
It makes your code more modular
Jacob Barber
@Jacoby6000
Jul 14 2017 19:04
yup
Edmund Noble
@edmundnoble
Jul 14 2017 19:04
Compared to Free I mean
Depending on what you do with it
Jacob Barber
@Jacoby6000
Jul 14 2017 19:06
I'll try to push for us to use tagless here, but I'm not sure I'll get much traction. That would require people to understand both context bounds and concepts like Monad
People seem a little reluctant to actually learn how to use a monad as an interface
Rob Norris
@tpolecat
Jul 14 2017 19:07
If you have a single algebra I think Free is simpler than tagless for the end user. Once you have coproducts it's kind of a wash because everything gets parameterized either way.
Edmund Noble
@edmundnoble
Jul 14 2017 19:07
That's a good point, but if your algebra gets transformed a lot it will change
andy scott
@andyscott
Jul 14 2017 19:07
Tagless has less boilerplate
Edmund Noble
@edmundnoble
Jul 14 2017 19:09
Yes and that's unavoidable with Free
I mean, it's "avoidable" ;) in the same sense all boilerplate in Scala is
Michael Pilquist
@mpilquist
Jul 14 2017 19:13
@edmundnoble I'm curious if you'd consider fs2 itself as tagless style
Edmund Noble
@edmundnoble
Jul 14 2017 19:13
You use Free[FreeApplicative[F, ?], A] in freestyle, yeah? You're becoming stack-safe with the new cats
@mpilquist I'd consider it to be... initially tagless, I suppose
It's initial I think for sure, because it's just Free over the algebra yeah?
Michael Pilquist
@mpilquist
Jul 14 2017 19:15
Internally, yeah
Edmund Noble
@edmundnoble
Jul 14 2017 19:16
Ultimately I think that explicit streaming may be fundamentally incompatible with final tagless
Michael Pilquist
@mpilquist
Jul 14 2017 19:16
I guess I mean the various non-primitive stuff on Stream, stuff like io project
Edmund Noble
@edmundnoble
Jul 14 2017 19:16
Oh!
Yes 100%
In FileHandle for example, that's classic final tagless
In fact that's something I also wanted in better-files :P
Michael Pilquist
@mpilquist
Jul 14 2017 19:18
Then make room on the hype train for me ;)
Edmund Noble
@edmundnoble
Jul 14 2017 19:18
Alright wonderful, there's still room
@adelbertc can move, he's taking up two seats ;)
andy scott
@andyscott
Jul 14 2017 19:20
:)
Edmund Noble
@edmundnoble
Jul 14 2017 19:23
I think that final tagless, despite not being usable to actually implement the stream itself (I think, it may be less performant if it's possible), may be the only way to create pure abstractions that use fs2 and don't have insane overhead induced by repeated Stream.translate calls
But I'm only guessing at the cost of Stream.translate based on Free.translate
(this is comparing it to using Stream[F, A] for F an initial algebra)
Raúl Raja Martínez
@raulraja
Jul 14 2017 19:42
RE freestyle-x or freestyle-y I think it's ok to be called a framework. akka-, cats-, ... we are all becoming frameworks ;). We are attempting to enforce all freestyle libs to be seamless to use when you are already using Free algebras or freestyle core.
So the prefix IMO helps users get instant information about the general design philosophy followed in the group of libraries.
Edmund Noble
@edmundnoble
Jul 14 2017 19:46
That's why I suggested frees as a prefix
I don't think it's teeechnically a framework so much as a convention for interfaces
I guess it's pretty fuzzy anyway
I mean either way, I wouldn't count cats or freestyle in the timperrett.com/2016/11/12/frameworks-are-fundimentally-broken/ bucket because they're both really modular for frameworks, and there's no IoC
Edmund Noble
@edmundnoble
Jul 14 2017 19:52
Also very general purpose
Raúl Raja Martínez
@raulraja
Jul 14 2017 20:23
100% agreed. frees is a good prefix too. frees-io/freestyle#383 let's see what folks think