# All files / src Relude_Validation.bs.js

67.67% Statements 90/133
46.67% Branches 14/30
34.29% Functions 12/35
67.67% Lines 90/133

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324

    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x

    5x

    6x

    1x

    1x

    13x
    3x

    10x

    25x
    9x

    16x

    77x
    23x
    23x
    17x

    6x

    54x
    17x

    37x

    43x

    2x

    2x

    48x
    24x

    24x

    17x
    17x
    17x
    17x
    77x

    17x

    17x
    17x

    17x
    17x

    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x
    17x

    17x

    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x

     'use strict';

    var Block = require("bs-platform/lib/js/block.js");
    var Curry = require("bs-platform/lib/js/curry.js");
    var Caml_option = require("bs-platform/lib/js/caml_option.js");
    var Relude_NonEmpty = require("./Relude_NonEmpty.bs.js");
    var Relude_Extensions_Apply = require("./extensions/Relude_Extensions_Apply.bs.js");
    var Relude_Extensions_Monad = require("./extensions/Relude_Extensions_Monad.bs.js");
    var Relude_Extensions_Functor = require("./extensions/Relude_Extensions_Functor.bs.js");
    var Relude_Extensions_Applicative = require("./extensions/Relude_Extensions_Applicative.bs.js");

    function ok(a) {
      return /* VOk */Block.__(0, [a]);
    }

    function error(e) {
      return /* VError */Block.__(1, [e]);
    }

    function isOk(param) {
      Iif (param.tag) {
        return false;
      } else {
        return true;
      }
    }

    function isError(a) {
      return !isOk(a);
    }

    function map(f, v) {
      if (v.tag) {
        return /* VError */Block.__(1, [v[0]]);
      } else {
        return /* VOk */Block.__(0, [Curry._1(f, v[0])]);
      }
    }

    function tap(f, fa) {
      return map((function (a) {
                    Curry._1(f, a);
                    return a;
                  }), fa);
    }

    function mapError(f, fa) {
      if (fa.tag) {
        return /* VError */Block.__(1, [Curry._1(f, fa[0])]);
      } else {
        return /* VOk */Block.__(0, [fa[0]]);
      }
    }

    function mapErrorsNea(f, fa) {
      if (fa.tag) {
        return /* VError */Block.__(1, [Relude_NonEmpty.$$Array[/* map */43](f, fa[0])]);
      } else {
        return fa;
      }
    }

    function mapErrorsNel(f, fa) {
      if (fa.tag) {
        return /* VError */Block.__(1, [Relude_NonEmpty.List[/* map */43](f, fa[0])]);
      } else {
        return fa;
      }
    }

    function tapError(f, fa) {
      return mapError((function (e) {
                    Curry._1(f, e);
                    return e;
                  }), fa);
    }

    function bimap(f, g, fa) {
      if (fa.tag) {
        return /* VError */Block.__(1, [Curry._1(g, fa[0])]);
      } else {
        return /* VOk */Block.__(0, [Curry._1(f, fa[0])]);
      }
    }

    function bitap(f, g, fa) {
      return bimap((function (a) {
                    Curry._1(f, a);
                    return a;
                  }), (function (e) {
                    Curry._1(g, e);
                    return e;
                  }), fa);
    }

    function applyWithAppendErrors(appendErrors, ff, fv) {
      if (ff.tag) {
        var e = ff[0];
        if (fv.tag) {
          return /* VError */Block.__(1, [Curry._2(appendErrors, e, fv[0])]);
        } else {
          return /* VError */Block.__(1, [e]);
        }
      } else if (fv.tag) {
        return /* VError */Block.__(1, [fv[0]]);
      } else {
        return /* VOk */Block.__(0, [Curry._1(ff[0], fv[0])]);
      }
    }

    function pure(a) {
      return /* VOk */Block.__(0, [a]);
    }

    function bind(fa, f) {
      Iif (fa.tag) {
        return /* VError */Block.__(1, [fa[0]]);
      } else {
        return Curry._1(f, fa[0]);
      }
    }

    function flatMap(f, fa) {
      return bind(fa, f);
    }

    function fromResult(result) {
      if (result.tag) {
        return /* VError */Block.__(1, [result[0]]);
      } else {
        return /* VOk */Block.__(0, [result[0]]);
      }
    }

    function toResult(validation) {
      if (validation.tag) {
        return /* Error */Block.__(1, [validation[0]]);
      } else {
        return /* Ok */Block.__(0, [validation[0]]);
      }
    }

    function fromOption(defaultError, opt) {
      if (opt !== undefined) {
        return /* VOk */Block.__(0, [Caml_option.valFromOption(opt)]);
      } else {
        return /* VError */Block.__(1, [defaultError]);
      }
    }

    function fromOptionLazy(getDefaultError, opt) {
      if (opt !== undefined) {
        return /* VOk */Block.__(0, [Caml_option.valFromOption(opt)]);
      } else {
        return /* VError */Block.__(1, [Curry._1(getDefaultError, /* () */0)]);
      }
    }

    function fold(ec, ac, r) {
      if (r.tag) {
        return Curry._1(ec, r[0]);
      } else {
        return Curry._1(ac, r[0]);
      }
    }

    function flip(fa) {
      return fold((function (e) {
                    return /* VOk */Block.__(0, [e]);
                  }), (function (a) {
                    return /* VError */Block.__(1, [a]);
                  }), fa);
    }

    function map2(appendErrors, f, fa, fb) {
      return applyWithAppendErrors(appendErrors, map(f, fa), fb);
    }

    function map3(appendErrors, f, fa, fb, fc) {
      return applyWithAppendErrors(appendErrors, map2(appendErrors, f, fa, fb), fc);
    }

    function map4(appendErrors, f, fa, fb, fc, fd) {
      return applyWithAppendErrors(appendErrors, map3(appendErrors, f, fa, fb, fc), fd);
    }

    function map5(appendErrors, f, fa, fb, fc, fd, fe) {
      return applyWithAppendErrors(appendErrors, map4(appendErrors, f, fa, fb, fc, fd), fe);
    }

    function WithErrors(Errors) {
      return (function ($$Error) {
          var Functor = /* module */[/* map */map];
          var include = Relude_Extensions_Functor.FunctorExtensions(Functor);
          var apply = function (ff, fa) {
            return applyWithAppendErrors(Errors[/* append */0], ff, fa);
          };
          var Apply = /* module */[
            /* map */map,
            /* apply */apply
          ];
          var include$1 = Relude_Extensions_Apply.ApplyExtensions(Apply);
          var Applicative = /* module */[
            /* map */map,
            /* apply */apply,
            /* pure */pure
          ];
          var include$2 = Relude_Extensions_Applicative.ApplicativeExtensions(Applicative);
          var Monad = /* module */[
            /* map */map,
            /* apply */apply,
            /* pure */pure,
            /* flat_map */bind
          ];
          var include$3 = Relude_Extensions_Monad.MonadExtensions(Monad);
          var include$4 = Relude_Extensions_Functor.FunctorInfix(Functor);
          var include$5 = Relude_Extensions_Apply.ApplyInfix(Apply);
          var include$6 = Relude_Extensions_Monad.MonadInfix(Monad);
          var Infix_000 = /* FunctorExtensions */include$4[0];
          var Infix_001 = /* <$> */include$4[1];
          var Infix_002 = /* <#> */include$4[2];
          var Infix_003 = /* <$ */include$4[3];
          var Infix_004 = /* $> */include$4[4];
          var Infix_005 = /* <@> */include$4[5];
          var Infix_006 = /* ApplyExtensions */include$5[0];
          var Infix_007 = /* <*> */include$5[1];
          var Infix_008 = /* <* */include$5[2];
          var Infix_009 = /* *> */include$5[3];
          var Infix_010 = /* MonadExtensions */include$6[0];
          var Infix_011 = /* >>= */include$6[1];
          var Infix_012 = /* =<< */include$6[2];
          var Infix_013 = /* >=> */include$6[3];
          var Infix_014 = /* <=< */include$6[4];
          var Infix = /* module */[
            Infix_000,
            Infix_001,
            Infix_002,
            Infix_003,
            Infix_004,
            Infix_005,
            Infix_006,
            Infix_007,
            Infix_008,
            Infix_009,
            Infix_010,
            Infix_011,
            Infix_012,
            Infix_013,
            Infix_014
          ];
          return /* module */[
                  /* Functor */Functor,
                  /* map */map,
                  /* BsFunctorExtensions */include[0],
                  /* flipMap */include[1],
                  /* void */include[2],
                  /* voidRight */include[3],
                  /* voidLeft */include[4],
                  /* flap */include[5],
                  /* Apply */Apply,
                  /* apply */apply,
                  /* BsApplyExtensions */include$1[0],
                  /* applyFirst */include$1[1],
                  /* applySecond */include$1[2],
                  /* map2 */include$1[3],
                  /* map3 */include$1[4],
                  /* map4 */include$1[5],
                  /* map5 */include$1[6],
                  /* tuple2 */include$1[7],
                  /* tuple3 */include$1[8],
                  /* tuple4 */include$1[9],
                  /* tuple5 */include$1[10],
                  /* mapTuple2 */include$1[11],
                  /* mapTuple3 */include$1[12],
                  /* mapTuple4 */include$1[13],
                  /* mapTuple5 */include$1[14],
                  /* Applicative */Applicative,
                  /* pure */pure,
                  /* BsApplicativeExtensions */include$2[0],
                  /* liftA1 */include$2[1],
                  /* Monad */Monad,
                  /* bind */bind,
                  /* BsMonadExtensions */include$3[0],
                  /* flatMap */include$3[1],
                  /* flatten */include$3[2],
                  /* composeKleisli */include$3[3],
                  /* flipComposeKleisli */include$3[4],
                  /* liftM1 */include$3[5],
                  /* when_ */include$3[6],
                  /* unless */include$3[7],
                  /* Infix */Infix
                ];
        });
    }

    exports.ok = ok;
    exports.error = error;
    exports.isOk = isOk;
    exports.isError = isError;
    exports.map = map;
    exports.tap = tap;
    exports.mapError = mapError;
    exports.mapErrorsNea = mapErrorsNea;
    exports.mapErrorsNel = mapErrorsNel;
    exports.tapError = tapError;
    exports.bimap = bimap;
    exports.bitap = bitap;
    exports.applyWithAppendErrors = applyWithAppendErrors;
    exports.pure = pure;
    exports.bind = bind;
    exports.flatMap = flatMap;
    exports.fromResult = fromResult;
    exports.toResult = toResult;
    exports.fromOption = fromOption;
    exports.fromOptionLazy = fromOptionLazy;
    exports.fold = fold;
    exports.flip = flip;
    exports.map2 = map2;
    exports.map3 = map3;
    exports.map4 = map4;
    exports.map5 = map5;
    exports.WithErrors = WithErrors;
    /* Relude_NonEmpty Not a pure module */