text: // Generated by psc version 0.10.7
  "use strict";
  var Prelude = require("../Prelude");
  var Data_Argonaut_Core = require("../Data.Argonaut.Core");
  var Data_Array = require("../Data.Array");
  var Data_Bifunctor = require("../Data.Bifunctor");
  var Data_Either = require("../Data.Either");
  var Data_Foldable = require("../Data.Foldable");
  var Data_Generic = require("../Data.Generic");
  var Data_Int = require("../Data.Int");
  var Data_List = require("../Data.List");
  var Data_Map = require("../Data.Map");
  var Data_Maybe = require("../Data.Maybe");
  var Data_String = require("../Data.String");
  var Data_StrMap = require("../Data.StrMap");
  var Data_Traversable = require("../Data.Traversable");
  var Data_Tuple = require("../Data.Tuple");
  var Type_Proxy = require("../Type.Proxy");
  var Control_Applicative = require("../Control.Applicative");
  var Data_Boolean = require("../Data.Boolean");
  var Data_Functor = require("../Data.Functor");
  var Data_List_Types = require("../Data.List.Types");
  var Control_Apply = require("../Control.Apply");
  var Control_Bind = require("../Control.Bind");
  var Data_Function = require("../Data.Function");
  var Data_Semigroup = require("../Data.Semigroup");
  var Data_Unit = require("../Data.Unit");
  var Control_Semigroupoid = require("../Control.Semigroupoid");
  var Data_Show = require("../Data.Show");
  var Data_Eq = require("../Data.Eq");
  var DecodeJson = function (decodeJson) {
      this.decodeJson = decodeJson;
  };
  var gDecodeJson$prime = function (signature) {
      return function (json) {
          var mFail = function (msg) {
              return Data_Maybe.maybe(new Data_Either.Left(msg))(Data_Either.Right.create);
          };
          if (signature instanceof Data_Generic.SigNumber) {
              return Data_Functor.map(Data_Either.functorEither)(Data_Generic.SNumber.create)(mFail("Expected a number")(Data_Argonaut_Core.toNumber(json)));
          };
          if (signature instanceof Data_Generic.SigInt) {
              return Data_Functor.map(Data_Either.functorEither)(Data_Generic.SInt.create)(mFail("Expected an integer number")(Control_Bind.bindFlipped(Data_Maybe.bindMaybe)(Data_Int.fromNumber)(Data_Argonaut_Core.toNumber(json))));
          };
          if (signature instanceof Data_Generic.SigString) {
              return Data_Functor.map(Data_Either.functorEither)(Data_Generic.SString.create)(mFail("Expected a string")(Data_Argonaut_Core.toString(json)));
          };
          if (signature instanceof Data_Generic.SigChar) {
              return Data_Functor.map(Data_Either.functorEither)(Data_Generic.SChar.create)(mFail("Expected a char")(Control_Bind.bindFlipped(Data_Maybe.bindMaybe)(Data_String.toChar)(Data_Argonaut_Core.toString(json))));
          };
          if (signature instanceof Data_Generic.SigBoolean) {
              return Data_Functor.map(Data_Either.functorEither)(Data_Generic.SBoolean.create)(mFail("Expected a boolean")(Data_Argonaut_Core.toBoolean(json)));
          };
          if (signature instanceof Data_Generic.SigUnit) {
              return Control_Applicative.pure(Data_Either.applicativeEither)(Data_Generic.SUnit.value);
          };
          if (signature instanceof Data_Generic.SigArray) {
              return Control_Bind.bind(Data_Either.bindEither)(mFail("Expected an array")(Data_Argonaut_Core.toArray(json)))(function (v) {
                  return Data_Functor.map(Data_Either.functorEither)(Data_Generic.SArray.create)(Data_Traversable.traverse(Data_Traversable.traversableArray)(Data_Either.applicativeEither)(function ($62) {
                      return Data_Functor.map(Data_Either.functorEither)(Data_Function["const"])(gDecodeJson$prime(signature.value0(Data_Unit.unit))($62));
                  })(v));
              });
          };
          if (signature instanceof Data_Generic.SigRecord) {
              return Control_Bind.bind(Data_Either.bindEither)(mFail("Expected an object")(Data_Argonaut_Core.toObject(json)))(function (v) {
                  return Data_Functor.map(Data_Either.functorEither)(Data_Generic.SRecord.create)(Data_Traversable["for"](Data_Either.applicativeEither)(Data_Traversable.traversableArray)(signature.value0)(function (v1) {
                      return Control_Bind.bind(Data_Either.bindEither)(mFail("'" + (v1.recLabel + "' property missing"))(Data_StrMap.lookup(v1.recLabel)(v)))(function (v2) {
                          return Control_Bind.bind(Data_Either.bindEither)(gDecodeJson$prime(v1.recValue(Data_Unit.unit))(v2))(function (v3) {
                              return Control_Applicative.pure(Data_Either.applicativeEither)({
                                  recLabel: v1.recLabel, 
                                  recValue: Data_Function["const"](v3)
                              });
                          });
                      });
                  }));
              });
          };
          if (signature instanceof Data_Generic.SigProd) {
              var decodingErr = function (msg) {
                  return "When decoding a " + (signature.value0 + (": " + msg));
              };
              return Control_Bind.bind(Data_Either.bindEither)(mFail(decodingErr("expected an object"))(Data_Argonaut_Core.toObject(json)))(function (v) {
                  return Control_Bind.bind(Data_Either.bindEither)(mFail(decodingErr("'tag' property is missing"))(Data_StrMap.lookup("tag")(v)))(function (v1) {
                      return Control_Bind.bind(Data_Either.bindEither)(mFail(decodingErr("'tag' property is not a string"))(Data_Argonaut_Core.toString(v1)))(function (v2) {
                          var $44 = Data_Foldable.find(Data_Foldable.foldableArray)(function ($63) {
                              return (function (v3) {
                                  return v2 === v3;
                              })((function (v3) {
                                  return v3.sigConstructor;
                              })($63));
                          })(signature.value1);
                          if ($44 instanceof Data_Maybe.Nothing) {
                              return new Data_Either.Left(decodingErr("'" + (v2 + "' isn't a valid constructor")));
                          };
                          if ($44 instanceof Data_Maybe.Just) {
                              return Control_Bind.bind(Data_Either.bindEither)(mFail(decodingErr("'values' array is missing"))(Control_Bind.bindFlipped(Data_Maybe.bindMaybe)(Data_Argonaut_Core.toArray)(Data_StrMap.lookup("values")(v))))(function (v3) {
                                  return Control_Bind.bind(Data_Either.bindEither)(Data_Array.zipWithA(Data_Either.applicativeEither)(function (k) {
                                      return gDecodeJson$prime(k(Data_Unit.unit));
                                  })($44.value0.sigValues)(v3))(function (v4) {
                                      return Control_Applicative.pure(Data_Either.applicativeEither)(new Data_Generic.SProd(v2, Data_Functor.map(Data_Functor.functorArray)(Data_Function["const"])(v4)));
                                  });
                              });
                          };
                          throw new Error("Failed pattern match at Data.Argonaut.Decode.Class line 60, column 5 - line 65, column 41: " + [ $44.constructor.name ]);
                      });
                  });
              });
          };
          throw new Error("Failed pattern match at Data.Argonaut.Decode.Class line 39, column 31 - line 65, column 41: " + [ signature.constructor.name ]);
      };
  };
  
  // | Decode `Json` representation of a value which has a `Generic` type.
  var gDecodeJson = function (dictGeneric) {
      return Control_Bind.composeKleisliFlipped(Data_Either.bindEither)(function ($64) {
          return Data_Maybe.maybe(new Data_Either.Left("fromSpine failed"))(Data_Either.Right.create)(Data_Generic.fromSpine(dictGeneric)($64));
      })(gDecodeJson$prime(Data_Generic.toSignature(dictGeneric)(Type_Proxy["Proxy"].value)));
  };
  var decodeJsonString = new DecodeJson(Data_Argonaut_Core.foldJsonString(new Data_Either.Left("Value is not a String"))(Data_Either.Right.create));
  var decodeJsonNumber = new DecodeJson(Data_Argonaut_Core.foldJsonNumber(new Data_Either.Left("Value is not a Number"))(Data_Either.Right.create));
  var decodeJsonNull = new DecodeJson(Data_Argonaut_Core.foldJsonNull(new Data_Either.Left("Value is not a null"))(Data_Function["const"](new Data_Either.Right(Data_Unit.unit))));
  var decodeJsonJson = new DecodeJson(Data_Either.Right.create);
  var decodeJsonBoolean = new DecodeJson(Data_Argonaut_Core.foldJsonBoolean(new Data_Either.Left("Value is not a Boolean"))(Data_Either.Right.create));
  var decodeJson = function (dict) {
      return dict.decodeJson;
  };
  var decodeJsonChar = new DecodeJson(function (j) {
      return Control_Bind.bindFlipped(Data_Either.bindEither)(Data_Maybe.maybe(Data_Either.Left.create("Expected character but found: " + Data_Show.show(Data_Argonaut_Core.showJson)(j)))(Data_Either.Right.create))(Data_Functor.map(Data_Either.functorEither)(Data_String.charAt(0))(decodeJson(decodeJsonString)(j)));
  });
  var decodeJsonInt = new DecodeJson(Control_Bind.composeKleisliFlipped(Data_Either.bindEither)(function ($65) {
      return Data_Maybe.maybe(new Data_Either.Left("Value is not an integer"))(Data_Either.Right.create)(Data_Int.fromNumber($65));
  })(decodeJson(decodeJsonNumber)));
  var decodeJsonMaybe = function (dictDecodeJson) {
      return new DecodeJson(function (j) {
          if (Data_Argonaut_Core.isNull(j)) {
              return Control_Applicative.pure(Data_Either.applicativeEither)(Data_Maybe.Nothing.value);
          };
          if (Data_Boolean.otherwise) {
              return Data_Functor.map(Data_Either.functorEither)(Data_Maybe.Just.create)(decodeJson(dictDecodeJson)(j));
          };
          throw new Error("Failed pattern match at Data.Argonaut.Decode.Class line 71, column 3 - line 73, column 40: " + [ j.constructor.name ]);
      });
  };
  var decodeJObject = function ($66) {
      return Data_Maybe.maybe(new Data_Either.Left("Value is not an Object"))(Data_Either.Right.create)(Data_Argonaut_Core.toObject($66));
  };
  var decodeJsonEither = function (dictDecodeJson) {
      return function (dictDecodeJson1) {
          return new DecodeJson(function (json) {
              return Data_Bifunctor.lmap(Data_Either.bifunctorEither)(function (v) {
                  return "Couldn't decode Either: " + v;
              })(Control_Bind.bind(Data_Either.bindEither)(decodeJObject(json))(function (obj) {
                  return Control_Bind.bind(Data_Either.bindEither)(Data_Maybe.maybe(new Data_Either.Left("Expected field 'tag'"))(Data_Either.Right.create)(Data_StrMap.lookup("tag")(obj)))(function (v) {
                      return Control_Bind.bind(Data_Either.bindEither)(Data_Maybe.maybe(new Data_Either.Left("Expected field 'value'"))(Data_Either.Right.create)(Data_StrMap.lookup("value")(obj)))(function (v1) {
                          var $54 = Data_Argonaut_Core.toString(v);
                          if ($54 instanceof Data_Maybe.Just && $54.value0 === "Right") {
                              return Data_Functor.map(Data_Either.functorEither)(Data_Either.Right.create)(decodeJson(dictDecodeJson1)(v1));
                          };
                          if ($54 instanceof Data_Maybe.Just && $54.value0 === "Left") {
                              return Data_Functor.map(Data_Either.functorEither)(Data_Either.Left.create)(decodeJson(dictDecodeJson)(v1));
                          };
                          return new Data_Either.Left("'tag' field was not \"Left\" or \"Right\"");
                      });
                  });
              }));
          });
      };
  };
  var decodeStrMap = function (dictDecodeJson) {
      return new DecodeJson(function ($67) {
          return Data_Bifunctor.lmap(Data_Either.bifunctorEither)(function (v) {
              return "Couldn't decode StrMap: " + v;
          })(Control_Bind.composeKleisliFlipped(Data_Either.bindEither)(Data_Traversable.traverse(Data_StrMap.traversableStrMap)(Data_Either.applicativeEither)(decodeJson(dictDecodeJson)))(decodeJObject)($67));
      });
  };
  var decodeJArray = function ($68) {
      return Data_Maybe.maybe(new Data_Either.Left("Value is not an Array"))(Data_Either.Right.create)(Data_Argonaut_Core.toArray($68));
  };
  var decodeList = function (dictDecodeJson) {
      return new DecodeJson(function ($69) {
          return Data_Bifunctor.lmap(Data_Either.bifunctorEither)(function (v) {
              return "Couldn't decode List: " + v;
          })(Control_Bind.composeKleisliFlipped(Data_Either.bindEither)(Data_Traversable.traverse(Data_List_Types.traversableList)(Data_Either.applicativeEither)(decodeJson(dictDecodeJson)))(Data_Functor.map(Data_Functor.functorFn)(Data_Functor.map(Data_Either.functorEither)(Data_List.fromFoldable(Data_Foldable.foldableArray)))(decodeJArray))($69));
      });
  };
  var decodeJsonTuple = function (dictDecodeJson) {
      return function (dictDecodeJson1) {
          return new DecodeJson(function (j) {
              var f = function (v) {
                  if (v instanceof Data_List_Types.Cons && (v.value1 instanceof Data_List_Types.Cons && v.value1.value1 instanceof Data_List_Types.Nil)) {
                      return Control_Apply.apply(Data_Either.applyEither)(Data_Functor.map(Data_Either.functorEither)(Data_Tuple.Tuple.create)(decodeJson(dictDecodeJson)(v.value0)))(decodeJson(dictDecodeJson1)(v.value1.value0));
                  };
                  return new Data_Either.Left("Couldn't decode Tuple");
              };
              return Control_Bind.bind(Data_Either.bindEither)(decodeJson(decodeList(decodeJsonJson))(j))(f);
          });
      };
  };
  var decodeMap = function (dictOrd) {
      return function (dictDecodeJson) {
          return function (dictDecodeJson1) {
              return new DecodeJson(function ($70) {
                  return Data_Functor.map(Data_Either.functorEither)(Data_Map.fromFoldable(dictOrd)(Data_List_Types.foldableList))(decodeJson(decodeList(decodeJsonTuple(dictDecodeJson)(dictDecodeJson1)))($70));
              });
          };
      };
  };
  var decodeArray = function (dictDecodeJson) {
      return new DecodeJson(function ($71) {
          return Data_Bifunctor.lmap(Data_Either.bifunctorEither)(function (v) {
              return "Couldn't decode Array: " + v;
          })(Control_Bind.composeKleisliFlipped(Data_Either.bindEither)(Data_Traversable.traverse(Data_Traversable.traversableArray)(Data_Either.applicativeEither)(decodeJson(dictDecodeJson)))(decodeJArray)($71));
      });
  };
  module.exports = {
      DecodeJson: DecodeJson, 
      decodeJson: decodeJson, 
      gDecodeJson: gDecodeJson, 
      "gDecodeJson'": gDecodeJson$prime, 
      decodeJsonMaybe: decodeJsonMaybe, 
      decodeJsonTuple: decodeJsonTuple, 
      decodeJsonEither: decodeJsonEither, 
      decodeJsonNull: decodeJsonNull, 
      decodeJsonBoolean: decodeJsonBoolean, 
      decodeJsonNumber: decodeJsonNumber, 
      decodeJsonInt: decodeJsonInt, 
      decodeJsonString: decodeJsonString, 
      decodeJsonJson: decodeJsonJson, 
      decodeJsonChar: decodeJsonChar, 
      decodeStrMap: decodeStrMap, 
      decodeArray: decodeArray, 
      decodeList: decodeList, 
      decodeMap: decodeMap
  };
  