typelevel / typelevel/toolkit

Opinionated default implementations of common tasks in scripts.

Open
#15 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
101
Forks
9
Avg merge
13m
Merged PRs (30d)
1

Description

Languages like python provide really fast and simple ways to perform most operations, which lends itself very well to scripting.
I think that Scala fails at this, while it's better than Java it's still not great. I don't think this is a problem for most situations.

I do however think it would be very nice if toolkit could provide default implementations of some common tasks in a referential transparent and resource-safe way. An example would be reading and writing files.

I'm pretty new to using CE so I ended up writing this, which I'm not even sure is the correct way to do this.

def fileWriter(path: String): Resource[IO, FileWriter] = 
    Resource.make(IO.blocking(new FileWriter(new File(name))))(file => IO.blocking(file.close()))
def openFile(path: String) : Resource[IO, Source] = 
    Resource.make(IO.blocking(Source.fromFile(path)))(file => IO.blocking(file.close()))

def writeToFile(path: String, content: String) =
    fileWriter(path).use(writer => IO.blocking(writer.write(content)))

if instead similar operations were already implemented for me I think that would be really great. It would at least make it a lot easier to convince other people to use this :)

All of this might obviously be outside of the scope of toolkit as it's a collection of libraries, but it would certainly make it easier to pick up for people who just want something to write small tools with.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by determining whether toolkit should cover common file-reading and file-writing tasks using cats-effect IO and Resource, then define the supported operations and completion criteria before locating the relevant library area.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.