Giter Site home page Giter Site logo

Purpose of this library about pos HOT 3 CLOSED

Kleidukos avatar Kleidukos commented on September 4, 2024
Purpose of this library

from pos.

Comments (3)

gbwey avatar gbwey commented on September 4, 2024

Good question. The main difference with Word is that Pos doesn't allow zero and does not provide a Num instance.
I excluded the Num instance so there would be fewer potential runtime errors arising from using fromIntegral/subtraction/negation.

Pos is designed to work with nonempty containers and in configuration where zero is invalid.
Examples:

  • The cybus package uses the Pos type with multidimensional arrays and indices where each dimension of the array is nonzero and the number of dimensions is nonzero
  • It is also used in the primus package for dealing with nonempty containers.
  • I use it in configuration where the number of cpus cannot be zero when running concurrent tasks; or where duration of a thread delay must be greater than zero.

Not having a Num instance for Pos is annoying, but the primus package provides a Num1 class that is a safer alternative to Num that respects the bounds of those numbers. So there are Num1 instances for Natural/Word/Pos etc.

from pos.

Kleidukos avatar Kleidukos commented on September 4, 2024

Awesome, thank you very much for this explanation!

from pos.

gbwey avatar gbwey commented on September 4, 2024

Glad that helped.

from pos.

Related Issues (1)

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.