Git Product home page Git Product logo

sly's Introduction

sly

sly

It's not hard to write pure functional code in Java. Just avoid mutability, avoid side effects, and focus on writing expressions instead of statements. This might seem like a lot to sacrifice in a language with a long history of procedural object-oriented programming, but all of the necessary language features to write pure functional code exist in Java and the experience is actually quite enjoyable.

sly is a functional framework built using lambda. The core principle of its design is to express common application needs in a type-safe pure functional style, and in discrete units that can be included as necessary.

Feature Areas

sly is organized into modules that implement discrete feature areas:

  • sly-app: An application wiring framework
  • sly-jdk: Utilities for working with JDK types
  • sly-lang: Functions and HyperFns for use in building algorithms
  • sly-model: Basic value types for modelling common application concerns

Additionally, sly includes these modules to aid in testing:

  • sly-hamcrest: Utilities for working with hamcrest
  • sly-jdk-matchers: Matchers for JDK types
  • sly-lambda-matchers: Matchers for lambda and other palatable types
  • sly-model-test: Matchers and fixtures for value types in sly-model

Contributing

sly is a work in progress, and I am having a lot of fun making progress. For now, I'd like to write the code myself and at my own pace. Please submit feature requests, bug reports, and questions at https://github.com/inkblot/sly/issues.

sly's People

Contributors

inkblot avatar

Watchers

 avatar  avatar Michael Anderson avatar

sly's Issues

Safe IO, and then a journey

I've been thinking a lot about the unsafePerformIO method of IO. I have two questions in particular that are on my mind. First, what would a hypothetical performIO method return? Second, why would it have to be an instance method of IO?

The answer to the first question almost suggests itself. While IO represents a deferred action that yields a result, with a possible alternative error state of Throwable, Try represents the result of performing an action which might be either a value or an error state of Throwable. So obviously a performIO on IO should return Try.

The second question has led me down a rabbit hole. This hypothetical performIO method is just a function from IO<A> to Try<A> with no opinion about A. It might as well be IO<?> to Try<?> except that it might be critical in a large number of use cases to unify the input and output carriers. Mathematically, this kind of function is a natural transformation, and shoki has a NaturalTransformation type that fits the mold, but it's kind of hard to use. I think I'd want it to have more convenient means of construction.

The only usage of the NaturalTransformation type is in the StreamT transformer, where it is the parameter to a mapStreamT method that turns a StreamT<M, A> into a StreamT<N, A> given a NaturalTransformation from the monad M to the monad N. The use is mystifying in its absence from other transformers. IterateT in lambda comes close with a mapIterateT that takes an Fn1 instead of a NaturalTransformation, but accomplishes the same goal of changing the argument monad of IterateT. Why don't other monad transformers offer this functionality? Why isn't StreamT's own mapStreamT method implemented as a NaturalTransformation? What other operations might be readily implemented in this form?

I'm starting to get motivated to fill this gap with code and see where it leads.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.