Giter Club home page Giter Club logo

enumerability's Introduction

enumerability

An enumeration is a complete, ordered listing of all the items in a collection. Enumerations are represented as functions from indices to values (a mapping from natural numbers to elements of the collection). The mapping can be partial (i.e. the enumeration may contain "holes") and elements can be repeated, as long as they all appear at least once. A type is a set of possible values. This package provides classes for enumerate and count almost any datatype.

Data.Enumerable

This module provides the Enumerable class, which computes the enumeration of any instance type.

ghci> take 20 $ enumerate :: [Int]
[0,1,-1,2,-2,3,-3,4,-4,5,-5,6,-6,7,-7,8,-8,9,-9,10]

ghci> take 10 $ enumerate :: [(Int, Bool)]
[(0,False),(1,False),(0,True),(-1,False),(1,True),(2,False),(-1,True),(-2,False),(2,True),(3,False)]

ghci> encode not
6

ghci> (decode 6 :: Maybe (Bool -> Bool)) <*> Just True
Just False

Instances for generic types can be automatically derived.

Data.Countable

This module provides the Countable class, which computes the cardinality of any instance type.

ghci> count :: Count Bool
Count {getCount = 2}

ghci> count :: Count (Bool -> Bool -> Bool)
Count {getCount = 16}

ghci> count :: Count [Void]
Count {getCount = 1}

Instances for generic types can be automatically derived.

enumerability's People

Contributors

jariazavalverde avatar

Watchers

 avatar  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.