Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which libraries? #1

Open
armanbilge opened this issue Feb 24, 2023 · 38 comments
Open

Which libraries? #1

armanbilge opened this issue Feb 24, 2023 · 38 comments
Labels
question Further information is requested

Comments

@armanbilge
Copy link
Member

The current choices mirror what's in the official Scala Toolkit (sttp, upickle, oslib). I also added Decline :)

toolkit/build.sbt

Lines 17 to 25 in e644ae5

libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % "2.9.0",
"org.typelevel" %%% "cats-effect" % "3.4.8",
"co.fs2" %%% "fs2-io" % "3.6.1",
"org.http4s" %%% "http4s-ember-client" % "0.23.18",
"io.circe" %%% "circe-core" % "0.14.4",
"org.http4s" %%% "http4s-circe" % "0.23.18",
"com.monovore" %%% "decline" % "2.4.1",
"org.typelevel" %%% "munit-cats-effect" % "2.0.0-M3" // not % Test, on purpose :)

But ... it's all bikesheddable :)

@armanbilge armanbilge added the question Further information is requested label Feb 24, 2023
@armanbilge armanbilge pinned this issue Feb 24, 2023
@TonioGela
Copy link
Member

TonioGela commented Feb 24, 2023

Since we're here, why not decline-effect? I prefer to do not have to reimplement CommandIOApp.

@armanbilge
Copy link
Member Author

Heh, my bad. Sure!

@TonioGela
Copy link
Member

TonioGela commented Feb 25, 2023

@lolgab made me notice that w/o importing epollcat the native flavour of the toolkit is quite useless atm.
Do we wanna add either epollcat only to the native build or namespacing the imports like toolkit.IOApp to take the correct implementation according to the platform?
Also, I'm aware of this PR but until it gets merged toolkit on its own is not sufficient for writing a native app

@armanbilge
Copy link
Member Author

on its own is not sufficient for writing a native app

Well, not for writing a native app that uses networking. But it's perfectly fine for file-based scripting.

The thing is, the toolkit can never be sufficient for this usecase, because the user also needs to install and configure s2n-tls anyway. So for Native, additional involvement will always be required, and as you point out it will get easier in the near future.

I almost considered not publishing for Native yet, but the file-scripting aspect seemed valuable.

@zetashift
Copy link
Contributor

May I suggest:

Because configs and parsing CSVs happen frequently enough (for me) to have them in the toolkit. However I very much understand the fact that it might be overkill.

@armanbilge
Copy link
Member Author

Ah, but the catch with fs2-data is that everything is in a separate module. So ... should we bring in all the modules? 😂 That might be overkill.

@zetashift
Copy link
Contributor

IMO, the CBOR and JSON modules don't need to be pulled in. I don't know what cbor is and we already have circe.
xml might be a nice to have, kinda depends. But I only ever had to deal with parsing XML once in my life sooooo.... :P

The csv saved my ass several times in scripts tho.

@TonioGela
Copy link
Member

TonioGela commented Feb 25, 2023

IMO, the CBOR and JSON modules don't need to be pulled in. I don't know what cbor is and we already have circe. xml might be a nice to have, kinda depends. But I only ever had to deal with parsing XML once in my life sooooo.... :P

The csv saved my ass several times in scripts tho.

IMHO, if we have to pick just one module, I'll pick the csv one. cbor might be funny to have since the VirtusLab toolkit has uPickle as a tiny serialization format, but it's probably a bit overkill too.

If this toolkit is supposed to be a pack of dependencies meant to be used for scripting purposes I think fs2-csv is a perfect fit, otoh I can't imagine the need for Ciris in a script-ish group of dependencies (unless at a certain point you do want to promote the script to a "beefier" application). What do you think?

@zetashift
Copy link
Contributor

I think that for now, only using the csv module is sufficient for the toolkit. Can always bikeshed later on, but for now I don't see their immediate gain.

If this toolkit is supposed to be a pack of dependencies meant to be used for scripting purposes

Not really related to this issue but, I think it's a good idea to state the goal of typelevels toolkit more explicitly in the README.md.
Personally, I'd like to see this project being used as a very low-entry easy-to-use standard library for making scripts/small applications using FP (or programs-as-values). I consider loading configs/secrets etc to be part of the "small applications" thing. Heck I'd even argue that http4s-server should be included as well (like Go's stdlib).

Thinking it through and seeing the nature of scala-cli and the fact that in smalls app, people would probably sooner switch to sbt or mill, I think I agree with you, there is no need for Ciris in scripts and thus also no (current) need for it to be included here. But maybe it can be re-considered again depending on use-cases developing over time.

@satabin
Copy link

satabin commented Mar 1, 2023

I agree with what has been said, in the context of scripting, fs2-data CSV (potentially the generic one even though it brings shapeless) would be a good fit here.

@TonioGela
Copy link
Member

Not really related to this issue but, I think it's a good idea to state the goal of typelevels toolkit more explicitly in the README.md.

I'm working on the site, and I was thinking about that. Probably claiming that it's MEANT to be used for scripting it's a strong claim.

I mean it's a meta lib that brings in CE, fs2, an http client, a json parser, a command line argument parser and a testing lib. It contains more features than most of the languages' standard lib have.

@zetashift
Copy link
Contributor

I mean it's a meta lib that brings in CE, fs2, an http client, a json parser, a command line argument parser and a testing lib. It contains more features than most of the languages' standard lib have.

True! And I can get behind this, but if this is a bikeshedding issue then I just felt obliged to do it :P.

Also is it okay if I open up the PR for fs2-data-csv?

@TonioGela
Copy link
Member

TonioGela commented Mar 3, 2023

Also is it okay if I open up the PR for fs2-data-csv?

Totally! go on :D
I count on you for a fs2-data-csv example for the site once it's ready :)

@TonioGela
Copy link
Member

@zetashift the site is live @ https://typelevel.org/toolkit, if you add a fs2-data-csv example we can hit the 0.0.3 release :)

@zetashift
Copy link
Contributor

On it!

@armanbilge
Copy link
Member Author

A discord question from @lenguyenthanh made me realize: shall we add Kittens? Automatic typeclass derivation sounds toolkitty to me :) at the very least for basic stuff like Show, Eq, maybe Monoid. anyone using it regularly?

https://github.com/typelevel/kittens

@lenguyenthanh
Copy link
Member

lenguyenthanh commented Apr 13, 2023

shall we add Kittens? Automatic typeclass derivation sounds toolkitty to me :) at the very least for basic stuff like Show, Eq, maybe Monoid. anyone using it regularly?

A yes for me, I started using it and definitely love it. It made me want to use type class more :D

@ChristopherDavenport
Copy link
Member

A couple ideas:

  • circe-parser (definitely get that string into json, particularly files)
  • circe-generic or generic-extras (both debateable, but if were doing automatic derivations here its a win for temporary script like stuff)

@armanbilge
Copy link
Member Author

armanbilge commented Apr 14, 2023

  • we currently have circe-jawn, which is a 100% identical API to circe-parser (just replace circe.parser with circe.jawn). On JS it is faster and not broken for numerics 😁

    We can switch to circe-parser in the next major Circe release which includes:
    Consider switching to the Jawn parser on JS circe/circe#1941
    Unfortunately we decided not to backport that to the 0.14.x series

  • 👍 to circe-generic but maybe only for Scala 2. On Scala 3 you can use derives with circe-core and I really hope nobody is trying to cross-build with toolkit because that sounds terrible 😁

@TonioGela
Copy link
Member

TonioGela commented Apr 14, 2023

A discord question from @lenguyenthanh made me realize: shall we add Kittens? Automatic typeclass derivation sounds toolkitty to me :) at the very least for basic stuff like Show, Eq, maybe Monoid. anyone using it regularly?

To be fair I don't use it that much, so I'm not sure which is the correct thing to do.
Toolkit is not limited to being used in small script-ish applications created with scala-cli but it's a fully-fledged library that can be used in huge sbt projects too. I'm just afraid that eventually it will include every TL library ever. What do you all think?

[EDIT] Now that I'm thinking about it I'll prefer to add small utility libs like mouse, but again, that's just my view :)

I really hope nobody is trying to cross-build with toolkit because that sounds terrible 😁

🤣

@armanbilge
Copy link
Member Author

I'm just afraid that eventually it will include every TL library ever.

Yep we are rapidly converging to this 😂

@lenguyenthanh
Copy link
Member

maybe this is a stupid idea, but how about a typelevel toolkit and typelevel fat toolkit (which includes everything lol)?

@TonioGela
Copy link
Member

I have the name: typewholevel

@zetashift
Copy link
Contributor

zetashift commented Apr 14, 2023

I am okay with libraries like kitten and mouse (mouse is really cool!).

Also a vote for https://github.com/typelevel/squants but this is more because F# has units of measures and I've found it very nice for small "business logic" focused applications.

I, personally, wouldn't like to have 2 versions of the toolkit. It just seems like more options, while one of it's nice properties is that it's just 1 import and it's just there. No need to think more about it unless you need some specific functionality.

I'd much rather have a "too big or too small" toolkit with endless bike shedding than having to explain when to use what. I want to think as little as possible when using toolkit.

--

How about some project templates (using giter8 or something) that includes a project.scala that imports a whole lot of TL libraries?
Or maybe a poll/survey for FP people to see what they would like to see included?
Dunno just throwing stuff out there :P.

@ppurang
Copy link

ppurang commented Jun 21, 2023

What's the motivation behind using munit instead of weaver-test?

@armanbilge
Copy link
Member Author

Arbitrary decisions :) we're considering changing to weaver, see discussion here.

@zetashift
Copy link
Contributor

Can't hurt to include MUnit + Weaver in the test artifact no? Atleast to start?

@armanbilge
Copy link
Member Author

@zetashift @ppurang there is a proposal to make Weaver an official Typelevel project, once that goes through I propose we add it / swap it out.

@zetashift
Copy link
Contributor

Here are 2 spicey suggestions:

  • http4s-server
  • circe-generic

Go, Zig and Node.js(Bun/Deno as well) all have a http server included in their standard library. So atleast it's worth bikeshedding about :P.

And circe-generic because I'm lazy to write manual codecs.

@armanbilge
Copy link
Member Author

Go, Zig and Node.js(Bun/Deno as well) all have a http server included in their standard library.

Yeah, ember-server. But then probably we'd need to bring in the http4s DSL as well, and that's opening cans and cans of worms :)


And circe-generic because I'm lazy to write manual codecs.

Actually you don't need it on Scala 3, derives works out-of-the-box. e.g.
https://github.com/typelevel/await-cirrus/blob/3f7307dc8a6775ef199735621254c320add46f8b/index.scala#L68

@zetashift
Copy link
Contributor

Go, Zig and Node.js(Bun/Deno as well) all have a http server included in their standard library.

Yeah, ember-server. But then probably we'd need to bring in the http4s DSL as well, and that's opening cans and cans of worms :)

🥲 life can be tough.

Actually you don't need it on Scala 3, derives works out-of-the-box. e.g. https://github.com/typelevel/await-cirrus/blob/3f7307dc8a6775ef199735621254c320add46f8b/index.scala#L68

Huh gotta revisit my scripts then, I had to pull in circe-generic for things to compile, using Scala 3 as well.

@SethTisue
Copy link
Member

SethTisue commented Nov 13, 2023

Maybe someone knowledgeable could add a section to the README with a list of the likeliest things people might want that aren't included, with links? This would mitigate the inconvenience/confusion factor in cases where including something seemed at least halfway plausible but a decision was made to leave it out.

At minimum, such a list would certainly include "http server". Not sure what else it would/should include.

After the list, there could even be a link to this ticket.

If there is some concise, beginner-friendly guide/map to the Typelevel ecosystem out there, linking to that, that'd be amazing too. Or to whatever the best available thing is, such as https://typelevel.org/projects/

@TonioGela
Copy link
Member

Go, Zig and Node.js(Bun/Deno as well) all have a http server included in their standard library.

Yeah, ember-server. But then probably we'd need to bring in the http4s DSL as well, and that's opening cans and cans of worms :)

🥲 life can be tough.

Actually you don't need it on Scala 3, derives works out-of-the-box. e.g. https://github.com/typelevel/await-cirrus/blob/3f7307dc8a6775ef199735621254c320add46f8b/index.scala#L68

Huh gotta revisit my scripts then, I had to pull in circe-generic for things to compile, using Scala 3 as well.

This seems like a spontaneous application for writing a auto derived json converting example

@zetashift
Copy link
Contributor

zetashift commented Nov 13, 2023

This seems like a spontaneous application for writing a auto derived json converting example

Just need the right inspiration for a runnable example!

@daddykotex
Copy link

Actually you don't need it on Scala 3, derives works out-of-the-box. e.g. https://github.com/typelevel/await-cirrus/blob/3f7307dc8a6775ef199735621254c320add46f8b/index.scala#L68

It seems to only work for Decoder

@TonioGela
Copy link
Member

TonioGela commented Nov 29, 2023

Actually you don't need it on Scala 3, derives works out-of-the-box. e.g. https://github.com/typelevel/await-cirrus/blob/3f7307dc8a6775ef199735621254c320add46f8b/index.scala#L68

It seems to only work for Decoder

//> using toolkit typelevel::latest
//> using scala 3.3.1

import io.circe.*
import io.circe.syntax.*

case class Foo(bar: String) derives Codec.AsObject

object Main extends App:
    println(Foo("hello").asJson.noSpaces)
{"bar":"hello"}

Codec and Encoder have a few implementations, namely AsObject, AsArray, AsRoot and AFAIK only AsObject has autoderivation ( I think this might be a question for circe not TL toolkit though :D )

@daddykotex
Copy link

Codec and Encoder have a few implementations, namely AsObject, AsArray, AsRoot and AFAIK only AsObject has autoderivation ( I think this might be a question for circe not TL toolkit though :D )

ahh makes sense, I completely overlooked that

@reardonj
Copy link
Contributor

I was playing around with Scala CLI today, for some simple HTTP client scripting. I was very surprised no XML library was included. I added http4s-fs2-data-xml-scala to get my use-case working but IMO, it would be very nice to have XML supported out of the box as it is the other common HTTP API data format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

10 participants