Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Opinionated default implementations of common tasks in scripts.

Đang mở
#15 9 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
scala
Lĩnh vực
tooling

Hướng nghiên cứu

Issue không nêu tệp, bài kiểm thử hay entry point nào. Trước tiên, hãy xác định liệu toolkit có nên hỗ trợ các tác vụ đọc và ghi tệp phổ biến bằng cats-effect IO và Resource hay không, sau đó xác định các thao tác được hỗ trợ và tiêu chí hoàn thành trước khi tìm khu vực thư viện liên quan.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Scala
Star
101
Fork
9
Merge trung bình
13 phút
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của typelevel/toolkit

Tất cả issue của typelevel/toolkit

Issue tương tự

Thêm issue về Scala

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.