Giter Club home page Giter Club logo

classy's Introduction

Classy

Software License Stability Travis

nimble

Haskell-style typeclasses for Nim.

Allows to instantiate collections of functions for a given type or type constructor.

Install

$ nimble install classy

Usage

import classy, future

typeclass Functor, F[_]:
  # proc map[A, B](fa: F[A], g: A -> B): F[B]
  proc `$>`[A, B](fa: F[A], b: B): F[B] =
    fa.map((a: A) => g)

instance Functor, seq[_]
assert: (@[1, 2, 3] $> "a") == @["a", "a", "a"]

Documentation

Module documentation is located here.

Also refer to example for a quick tutorial.

Testing

$ nimble tests

Stability

Highly experimental. API and behaviour subject to change.

Credits

License

The Unlicense. Please see License File for more information.

classy's People

Contributors

krux02 avatar nigredo-tori avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

classy's Issues

Please keep this project alive!

This project is a milestone for applying functional programming patterns in nim, it deserves some love!

For example, this blocking issue has been upgraded:
nim-lang/Nim#4104

also {.noSideEffect.} and {.raises: [].} can be added where needed to enforce some fp goodness

How to write Haskell style code assuming type classes ?

In Haskell you can do

foo: Show a; a -> IO ()
foo = print . show
-- same as  foo a = print (show a)

How would such be done with classy ? I am still new to nim.
The point is thaht Show is the typeclass and a is the type parameter.

Don't inject unused parameters

typeclass A, [F, G]:
  proc foo(f: F)

instance A, [X, Y] => [Option[X], Option[Y]]

should give the following:

proc foo[X](f: Option[X])

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.