Git Product home page Git Product logo

fantasy-maybes's People

Contributors

davidchambers avatar puffnfresh avatar simonrichardson avatar wemrysi 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fantasy-maybes's Issues

Example of OptionT

Hi,

I am trying to use OptionT with the State monad from fantasy-states for handling errors in stateful computations. Are there any examples that I can refer to?

Option versus Maybe

I'm excited by the discussion in ramda/ramda-fantasy#139.

One potential problem has become apparent to me: there are two common names for this data type. Haskell uses "Maybe"; Scala uses "Option". Neither is better or worse than the other, but there are contexts in which one is more appropriate than the other. Sanctuary, for example, is strongly inspired by Haskell and PureScript so uses "Maybe", whereas Folktale draws inspiration from Scalaz and Cats (I believe), so uses "Option".

Since the goal is for this project is to be the canonical implementation of the Maybe/Option type, it would be nice if we could somehow please everyone. While someone could easily include…

const Nothing = None;
const Just = Some;

in her own code to use the "Haskell" data constructors, the string representation of Just(42) would still be 'Some(42)'.

I'm thinking through the ramifications of merging Sanctuary's Maybe type into this repository. Since Sanctuary is inspired by Haskell and PureScript I certainly want to keep using "Maybe" in that project, and I certainly don't want to monkey patch Option#toString.

Perhaps this project should export both Maybe and Option:

exports.Maybe = create('Nothing', 'Just');
exports.Option = create('None', 'Some');
const {Nothing, Just} = require('fantasy-options').Maybe;
const {None, Some} = require('fantasy-options').Option;

Maybe and Option would really be two names for the same type. Just(42) and Some(42) would be interchangeable, though they would have different string representations.

I realize the thoughts I'm sharing are not fully formed. My goal is to start a discussion rather than to propose a specific solution.

isNone function in tests is not valid function

https://github.com/fantasyland/fantasy-options/blob/master/test/option.js#L42

Not an issue with the actual library. isNone is never actually used in the testing either, just defined. If someone stumbles upon it and uses it in their code it will just lead to confusion. In daggy.js taggedSums doesn't actually create a constructor for keys with values of zero length.

Here's my implementation of isNone:

var isNone = function(o){
   return isOption(o) && not(isSome(o))
}

I was using bilby.js before so this confused me a little.

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.