Git Product home page Git Product logo

cluss's Introduction

cluss

simple alternative to type classes

A cluss enables you to achieve function overloading, or ad-hoc polymorphism, without creating a new type class.

In order to give ad-hoc polymorphism to a type variable a, you simply use In with a list of "type patterns" like In [Type T, ...] a, which indicates that the type matches some of the patterns; which is analogous to a type class indicating that a type matches some of its "instances". The constraint In [Type T, ...] a is what we call a "cluss".

Clusses can easily be used in a nested way and even be recursive; therefore, they are expressive enough to imitate Haskell-98-style type classes.

Clusses, however, go beyond a mere alternative to type classes. They have closed and prioritized instances and open methods, while type classes have open and unprioritized instances and closed methods. Those properties give clusses the advantages different from type classes:

  • You can judge whether a type a belongs to a cluss In as, on some level, writing Has as a, since cluss instances are closed.

  • You can make cluss instances more flexibly, without causing overlapping instances or incoherent instances, since cluss instances are prioritized.

  • You can create new methods for clusses anywhere in any module, since cluss methods are open.

More information can be found in the hackage's haddock or the updated haddock.

The latest version is available at https://hackage.haskell.org/package/cluss.

cluss's People

Contributors

shiatsumat avatar

Watchers

 avatar

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.