{"version":3,"sources":["webpack:///./node_modules/data.maybe/lib/index.js","webpack:///./node_modules/data.maybe/lib/maybe.js"],"names":["module","exports","Maybe","clone","Object","create","unimplemented","Error","noop","this","Just","a","value","Nothing","prototype","fromNullable","fromEither","fold","fromValidation","isNothing","isJust","of","ap","b","map","f","chain","toString","isEqual","get","TypeError","getOrElse","_","orElse","cata","pattern","toJSON"],"mappings":"8EAqBAA,EAAOC,QAAU,EAAQ,M,kBCGzBD,EAAOC,QAAUC,MAGjB,IAAIC,EAAgBC,OAAOC,OACvBC,cAAgB,WAAY,MAAM,IAAIC,MAAM,qBAC5CC,KAAgB,WAAY,OAAOC,MA2CvC,SAASP,SAIT,SAASQ,KAAKC,GACZF,KAAKG,MAAQD,EAKf,SAASE,WAPTH,KAAKI,UAAYX,EAAMD,MAAMY,WAM7BD,QAAQC,UAAYX,EAAMD,MAAMY,WAYhCZ,MAAMW,QAAU,WACd,OAAO,IAAIA,SAEbX,MAAMY,UAAUD,QAAUX,MAAMW,QAWhCX,MAAMQ,KAAO,SAASC,GACpB,OAAO,IAAID,KAAKC,IAElBT,MAAMY,UAAUJ,KAAOR,MAAMQ,KAa7BR,MAAMa,aAAe,SAASJ,GAC5B,OAAY,MAALA,EAAiB,IAAID,KAAKC,GACT,IAAIE,SAE9BX,MAAMY,UAAUC,aAAeb,MAAMa,aAUrCb,MAAMc,WAAa,SAASL,GAC1B,OAAOA,EAAEM,KAAKf,MAAMW,QAASX,MAAMQ,OAErCR,MAAMY,UAAUE,WAAad,MAAMc,WAWnCd,MAAMgB,eAA2BhB,MAAMc,WACvCd,MAAMY,UAAUI,eAAiBhB,MAAMc,WAUvCd,MAAMY,UAAUK,WAAc,EAC9BN,QAAQC,UAAUK,WAAY,EAQ9BjB,MAAMY,UAAUM,QAAS,EACzBV,KAAKI,UAAUM,QAAU,EAazBlB,MAAMmB,GAAK,SAASV,GAClB,OAAO,IAAID,KAAKC,IAElBT,MAAMY,UAAUO,GAAKnB,MAAMmB,GAa3BnB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SAASC,GAC7B,OAAOA,EAAQzB,KAAKD,KAAKG,QAU3BV,MAAMY,UAAUsB,OAAS9B,cAEzBO,QAAQC,UAAUsB,OAAS,WACzB,MAAO,CAAE,QAAS,2BAGpB1B,KAAKI,UAAUsB,OAAS,WACtB,MAAO,CAAE,QAAS,sBACTxB,MAAOH,KAAKG","file":"npm.data.maybe-ddf2e414046cf230a2da.js","sourcesContent":["// Copyright (c) 2013-2014 Quildreen Motta \n//\n// Permission is hereby granted, free of charge, to any person\n// obtaining a copy of this software and associated documentation files\n// (the \"Software\"), to deal in the Software without restriction,\n// including without limitation the rights to use, copy, modify, merge,\n// publish, distribute, sublicense, and/or sell copies of the Software,\n// and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be\n// included in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nmodule.exports = require('./maybe')","// Copyright (c) 2013-2014 Quildreen Motta \n//\n// Permission is hereby granted, free of charge, to any person\n// obtaining a copy of this software and associated documentation files\n// (the \"Software\"), to deal in the Software without restriction,\n// including without limitation the rights to use, copy, modify, merge,\n// publish, distribute, sublicense, and/or sell copies of the Software,\n// and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be\n// included in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n/**\n * @module lib/maybe\n */\nmodule.exports = Maybe\n\n// -- Aliases ----------------------------------------------------------\nvar clone = Object.create\nvar unimplemented = function(){ throw new Error('Not implemented.') }\nvar noop = function(){ return this }\n\n// -- Implementation ---------------------------------------------------\n\n/**\n * A structure for values that may not be present, or computations that may\n * fail. `Maybe(a)` explicitly models the effects that are implicit in\n * `Nullable` types, thus has none of the problems associated with\n * `null` or `undefined` — like `NullPointerExceptions`.\n *\n * The class models two different cases:\n *\n * + `Just a` — represents a `Maybe(a)` that contains a value. `a` may\n * be any value, including `null` or `undefined`.\n *\n * + `Nothing` — represents a `Maybe(a)` that has no values. Or a\n * failure that needs no additional information.\n *\n * Common uses of this structure includes modelling values that may or may\n * not be present in a collection, thus instead of needing a\n * `collection.has(a)`, the `collection.get(a)` operation gives you all\n * the information you need — `collection.get(a).is-nothing` being\n * equivalent to `collection.has(a)`; Similarly the same reasoning may\n * be applied to computations that may fail to provide a value, e.g.:\n * `collection.find(predicate)` can safely return a `Maybe(a)` instance,\n * even if the collection contains nullable values.\n *\n * Furthermore, the values of `Maybe(a)` can be combined and manipulated\n * by using the expressive monadic operations. This allows safely\n * sequencing operations that may fail, and safely composing values that\n * you don't know whether they're present or not, failing early\n * (returning a `Nothing`) if any of the operations fail.\n *\n * If one wants to store additional information about failures, the\n * [Either][] and [Validation][] structures provide such a capability, and\n * should be used instead of the `Maybe(a)` structure.\n *\n * [Either]: https://github.com/folktale/data.either\n * [Validation]: https://github.com/folktale/data.validation\n *\n *\n * @class\n */\nfunction Maybe() {}\n\n// The case for successful values\nJust.prototype = clone(Maybe.prototype)\nfunction Just(a){\n this.value = a\n}\n\n// The case for failure values\nNothing.prototype = clone(Maybe.prototype)\nfunction Nothing(){}\n\n\n// -- Constructors -----------------------------------------------------\n\n/**\n * Constructs a new `Maybe[α]` structure with an absent value. Commonly used\n * to represent a failure.\n *\n * @summary Void → Maybe[α]\n */\nMaybe.Nothing = function() {\n return new Nothing\n}\nMaybe.prototype.Nothing = Maybe.Nothing\n\n/**\n * Constructs a new `Maybe[α]` structure that holds the single value\n * `α`. Commonly used to represent a success.\n *\n * `α` can be any value, including `null`, `undefined` or another\n * `Maybe[α]` structure.\n *\n * @summary α → Maybe[α]\n */\nMaybe.Just = function(a) {\n return new Just(a)\n}\nMaybe.prototype.Just = Maybe.Just\n\n\n// -- Conversions ------------------------------------------------------\n\n/**\n * Constructs a new `Maybe[α]` structure from a nullable type.\n *\n * If the value is either `null` or `undefined`, this function returns a\n * `Nothing`, otherwise the value is wrapped in a `Just(α)`.\n *\n * @summary α → Maybe[α]\n */\nMaybe.fromNullable = function(a) {\n return a != null? new Just(a)\n : /* otherwise */ new Nothing\n}\nMaybe.prototype.fromNullable = Maybe.fromNullable\n\n/**\n * Constructs a new `Maybe[β]` structure from an `Either[α, β]` type.\n *\n * The left side of the `Either` becomes `Nothing`, and the right side\n * is wrapped in a `Just(β)`.\n *\n * @summary Either[α, β] → Maybe[β]\n */\nMaybe.fromEither = function(a) {\n return a.fold(Maybe.Nothing, Maybe.Just)\n}\nMaybe.prototype.fromEither = Maybe.fromEither\n\n/**\n * Constructs a new `Maybe[β]` structure from a `Validation[α, β]` type.\n *\n * The failure side of the `Validation` becomes `Nothing`, and the right\n * side is wrapped in a `Just(β)`.\n *\n * @method\n * @summary Validation[α, β] → Maybe[β]\n */\nMaybe.fromValidation = Maybe.fromEither\nMaybe.prototype.fromValidation = Maybe.fromEither\n\n\n// -- Predicates -------------------------------------------------------\n\n/**\n * True if the `Maybe[α]` structure contains a failure (i.e.: `Nothing`).\n *\n * @summary Boolean\n */\nMaybe.prototype.isNothing = false\nNothing.prototype.isNothing = true\n\n\n/**\n * True if the `Maybe[α]` structure contains a single value (i.e.: `Just(α)`).\n *\n * @summary Boolean\n */\nMaybe.prototype.isJust = false\nJust.prototype.isJust = true\n\n\n// -- Applicative ------------------------------------------------------\n\n/**\n * Creates a new `Maybe[α]` structure holding the single value `α`.\n *\n * `α` can be any value, including `null`, `undefined`, or another\n * `Maybe[α]` structure.\n *\n * @summary α → Maybe[α]\n */\nMaybe.of = function(a) {\n return new Just(a)\n}\nMaybe.prototype.of = Maybe.of\n\n\n/**\n * Applies the function inside the `Maybe[α]` structure to another\n * applicative type.\n *\n * The `Maybe[α]` structure should contain a function value, otherwise a\n * `TypeError` is thrown.\n *\n * @method\n * @summary (@Maybe[α → β], f:Applicative[_]) => f[α] → f[β]\n */\nMaybe.prototype.ap = unimplemented\n\nNothing.prototype.ap = noop\n\nJust.prototype.ap = function(b) {\n return b.map(this.value)\n}\n\n\n\n\n// -- Functor ----------------------------------------------------------\n\n/**\n * Transforms the value of the `Maybe[α]` structure using a regular unary\n * function.\n *\n * @method\n * @summary @Maybe[α] => (α → β) → Maybe[β]\n */\nMaybe.prototype.map = unimplemented\nNothing.prototype.map = noop\n\nJust.prototype.map = function(f) {\n return this.of(f(this.value))\n}\n\n\n// -- Chain ------------------------------------------------------------\n\n/**\n * Transforms the value of the `Maybe[α]` structure using an unary function\n * to monads.\n *\n * @method\n * @summary (@Maybe[α], m:Monad[_]) => (α → m[β]) → m[β]\n */\nMaybe.prototype.chain = unimplemented\nNothing.prototype.chain = noop\n\nJust.prototype.chain = function(f) {\n return f(this.value)\n}\n\n\n// -- Show -------------------------------------------------------------\n\n/**\n * Returns a textual representation of the `Maybe[α]` structure.\n *\n * @method\n * @summary @Maybe[α] => Void → String\n */\nMaybe.prototype.toString = unimplemented\n\nNothing.prototype.toString = function() {\n return 'Maybe.Nothing'\n}\n\nJust.prototype.toString = function() {\n return 'Maybe.Just(' + this.value + ')'\n}\n\n\n// -- Eq ---------------------------------------------------------------\n\n/**\n * Tests if a `Maybe[α]` structure is equal to another `Maybe[α]` structure.\n *\n * @method\n * @summary @Maybe[α] => Maybe[α] → Boolean\n */\nMaybe.prototype.isEqual = unimplemented\n\nNothing.prototype.isEqual = function(b) {\n return b.isNothing\n}\n\nJust.prototype.isEqual = function(b) {\n return b.isJust\n && b.value === this.value\n}\n\n\n// -- Extracting and recovering ----------------------------------------\n\n/**\n * Extracts the value out of the `Maybe[α]` structure, if it\n * exists. Otherwise throws a `TypeError`.\n *\n * @method\n * @summary @Maybe[α] => Void → a, :: partial, throws\n * @see {@link module:lib/maybe~Maybe#getOrElse} — A getter that can handle failures\n * @throws {TypeError} if the structure has no value (`Nothing`).\n */\nMaybe.prototype.get = unimplemented\n\nNothing.prototype.get = function() {\n throw new TypeError(\"Can't extract the value of a Nothing.\")\n}\n\nJust.prototype.get = function() {\n return this.value\n}\n\n\n/**\n * Extracts the value out of the `Maybe[α]` structure. If there is no value,\n * returns the given default.\n *\n * @method\n * @summary @Maybe[α] => α → α\n */\nMaybe.prototype.getOrElse = unimplemented\n\nNothing.prototype.getOrElse = function(a) {\n return a\n}\n\nJust.prototype.getOrElse = function(_) {\n return this.value\n}\n\n\n/**\n * Transforms a failure into a new `Maybe[α]` structure. Does nothing if the\n * structure already contains a value.\n *\n * @method\n * @summary @Maybe[α] => (Void → Maybe[α]) → Maybe[α]\n */\nMaybe.prototype.orElse = unimplemented\n\nNothing.prototype.orElse = function(f) {\n return f()\n}\n\nJust.prototype.orElse = function(_) {\n return this\n}\n\n\n/**\n * Catamorphism.\n * \n * @method\n * @summary @Maybe[α] => { Nothing: Void → β, Just: α → β } → β\n */\nMaybe.prototype.cata = unimplemented\n\nNothing.prototype.cata = function(pattern) {\n return pattern.Nothing()\n}\n\nJust.prototype.cata = function(pattern) {\n return pattern.Just(this.value);\n}\n\n\n/**\n * JSON serialisation\n *\n * @method\n * @summary @Maybe[α] => Void → Object\n */\nMaybe.prototype.toJSON = unimplemented\n\nNothing.prototype.toJSON = function() {\n return { '#type': 'folktale:Maybe.Nothing' }\n}\n\nJust.prototype.toJSON = function() {\n return { '#type': 'folktale:Maybe.Just'\n , value: this.value }\n}\n"],"sourceRoot":""}