From 02986c0bfc9775cf2fc563deea0b9827658e477c Mon Sep 17 00:00:00 2001 From: Serhii Khoma Date: Wed, 9 Oct 2024 18:26:55 +0700 Subject: [PATCH 1/2] feat: migrate to spago@next --- .github/workflows/ci.yml | 37 + spago.lock | 1276 +++++++++++++++++++++++ spago.yaml | 38 + src/Polyform/Dual/Variant.js | 2 +- test/{ => Test}/Main.purs | 0 test/{ => Test}/Polyform/Reporter.purs | 9 +- test/{ => Test}/Polyform/Validator.purs | 10 +- 7 files changed, 1363 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 spago.lock create mode 100644 spago.yaml rename test/{ => Test}/Main.purs (100%) rename test/{ => Test}/Polyform/Reporter.purs (93%) rename test/{ => Test}/Polyform/Validator.purs (93%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..611c609 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI + +on: + push: + branches: [master, main] + pull_request: + branches: [master, main] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up a PureScript toolchain + uses: purescript-contrib/setup-purescript@main + with: + purescript: "latest" + purs-tidy: "latest" + spago: "unstable" + + - name: Cache PureScript dependencies + uses: actions/cache@v4 + with: + key: ${{ runner.os }}-spago-${{ hashFiles('**/spago.lock') }} + path: | + .spago + output + + - name: Build source + run: spago build --censor-stats --strict --pedantic-packages + + - name: Run tests + run: spago test --offline --censor-stats --strict --pedantic-packages -- --censor-codes=UserDefinedWarning + + - name: Verify formatting + run: purs-tidy check src test diff --git a/spago.lock b/spago.lock new file mode 100644 index 0000000..e2b58ca --- /dev/null +++ b/spago.lock @@ -0,0 +1,1276 @@ +{ + "workspace": { + "packages": { + "polyform": { + "path": "./", + "core": { + "dependencies": [ + "bifunctors", + "control", + "either", + "functors", + "heterogeneous", + "identity", + "invariant", + "lists", + "maybe", + "newtype", + "ordered-collections", + "parallel", + "partial", + "prelude", + "profunctor", + "record", + "transformers", + "tuples", + "type-equality", + "typelevel-prelude", + "unsafe-coerce", + "validation", + "variant" + ], + "build_plan": [ + "arrays", + "bifunctors", + "const", + "contravariant", + "control", + "distributive", + "effect", + "either", + "enums", + "exceptions", + "exists", + "foldable-traversable", + "functions", + "functors", + "gen", + "heterogeneous", + "identity", + "invariant", + "lazy", + "lists", + "maybe", + "newtype", + "nonempty", + "ordered-collections", + "orders", + "parallel", + "partial", + "prelude", + "profunctor", + "record", + "refs", + "safe-coerce", + "st", + "tailrec", + "transformers", + "tuples", + "type-equality", + "typelevel-prelude", + "unfoldable", + "unsafe-coerce", + "validation", + "variant" + ] + }, + "test": { + "dependencies": [ + "arrays", + "effect", + "enums", + "quickcheck", + "quickcheck-laws" + ], + "build_plan": [ + "arrays", + "bifunctors", + "console", + "const", + "contravariant", + "control", + "distributive", + "effect", + "either", + "enums", + "exceptions", + "exists", + "foldable-traversable", + "functions", + "functors", + "gen", + "identity", + "integers", + "invariant", + "lazy", + "lcg", + "lists", + "maybe", + "newtype", + "nonempty", + "numbers", + "orders", + "partial", + "prelude", + "profunctor", + "quickcheck", + "quickcheck-laws", + "random", + "record", + "refs", + "safe-coerce", + "st", + "strings", + "tailrec", + "transformers", + "tuples", + "type-equality", + "unfoldable", + "unsafe-coerce" + ] + } + } + }, + "package_set": { + "address": { + "registry": "60.4.0" + }, + "compiler": ">=0.15.15 <0.16.0", + "content": { + "abc-parser": "2.0.1", + "ace": "9.1.0", + "address-rfc2821": "0.1.1", + "aff": "8.0.0", + "aff-bus": "6.0.0", + "aff-coroutines": "9.0.0", + "aff-promise": "4.0.0", + "aff-retry": "2.0.0", + "affjax": "13.0.0", + "affjax-node": "1.0.0", + "affjax-web": "1.0.0", + "ansi": "7.0.0", + "apexcharts": "0.5.0", + "applicative-phases": "1.0.0", + "argonaut": "9.0.0", + "argonaut-aeson-generic": "0.4.1", + "argonaut-codecs": "9.1.0", + "argonaut-core": "7.0.0", + "argonaut-generic": "8.0.0", + "argonaut-traversals": "10.0.0", + "argparse-basic": "2.0.0", + "array-builder": "0.1.2", + "array-search": "0.6.0", + "arraybuffer": "13.2.0", + "arraybuffer-builder": "3.1.0", + "arraybuffer-types": "3.0.2", + "arrays": "7.3.0", + "arrays-extra": "0.6.1", + "arrays-zipper": "2.0.1", + "ask": "1.0.0", + "assert": "6.0.0", + "assert-multiple": "0.4.0", + "avar": "5.0.0", + "b64": "0.0.8", + "barbies": "1.0.1", + "barlow-lens": "0.9.0", + "bifunctors": "6.0.0", + "bigints": "7.0.1", + "bolson": "0.3.9", + "bookhound": "0.1.7", + "bower-json": "3.0.0", + "call-by-name": "4.0.1", + "canvas": "6.0.0", + "canvas-action": "9.0.0", + "cartesian": "1.0.6", + "catenable-lists": "7.0.0", + "cbor-stream": "1.3.0", + "chameleon": "1.0.0", + "chameleon-halogen": "1.0.3", + "chameleon-react-basic": "1.1.0", + "chameleon-styled": "2.5.0", + "chameleon-transformers": "1.0.0", + "channel": "1.0.0", + "checked-exceptions": "3.1.1", + "choku": "1.0.1", + "classless": "0.1.1", + "classless-arbitrary": "0.1.1", + "classless-decode-json": "0.1.1", + "classless-encode-json": "0.1.3", + "classnames": "2.0.0", + "codec": "6.1.0", + "codec-argonaut": "10.0.0", + "codec-json": "2.0.0", + "colors": "7.0.1", + "concur-core": "0.5.0", + "concur-react": "0.5.0", + "concurrent-queues": "3.0.0", + "console": "6.1.0", + "const": "6.0.0", + "contravariant": "6.0.0", + "control": "6.0.0", + "convertable-options": "1.0.0", + "coroutines": "7.0.0", + "css": "6.0.0", + "css-frameworks": "1.0.1", + "csv-stream": "2.3.0", + "data-mvc": "0.0.2", + "datetime": "6.1.0", + "datetime-parsing": "0.2.0", + "debounce": "0.1.0", + "debug": "6.0.2", + "decimals": "7.1.0", + "default-values": "1.0.1", + "deku": "0.9.23", + "deno": "0.0.5", + "dissect": "1.0.0", + "distributive": "6.0.0", + "dom-filereader": "7.0.0", + "dom-indexed": "12.0.0", + "dom-simple": "0.4.0", + "dotenv": "4.0.3", + "droplet": "0.6.0", + "dts": "1.0.0", + "dual-numbers": "1.0.3", + "dynamic-buffer": "3.0.1", + "echarts-simple": "0.0.1", + "effect": "4.0.0", + "either": "6.1.0", + "elmish": "0.13.0", + "elmish-enzyme": "0.1.1", + "elmish-hooks": "0.10.3", + "elmish-html": "0.9.0", + "elmish-testing-library": "0.3.2", + "email-validate": "7.0.0", + "encoding": "0.0.9", + "enums": "6.0.1", + "env-names": "0.4.0", + "error": "2.0.0", + "eta-conversion": "0.3.2", + "exceptions": "6.1.0", + "exists": "6.0.0", + "exitcodes": "4.0.0", + "expect-inferred": "3.0.0", + "ezfetch": "1.0.0", + "fahrtwind": "2.0.0", + "fallback": "0.1.0", + "fast-vect": "1.2.0", + "fetch": "4.1.0", + "fetch-argonaut": "1.0.1", + "fetch-core": "5.1.0", + "fetch-yoga-json": "1.1.0", + "ffi-simple": "0.5.1", + "fft-js": "0.1.0", + "filterable": "5.0.0", + "fix-functor": "0.1.0", + "fixed-points": "7.0.0", + "fixed-precision": "5.0.0", + "flame": "1.3.0", + "float32": "2.0.0", + "fmt": "0.2.1", + "foldable-traversable": "6.0.0", + "foldable-traversable-extra": "0.0.6", + "foreign": "7.0.0", + "foreign-object": "4.1.0", + "foreign-readwrite": "3.4.0", + "forgetmenot": "0.1.0", + "fork": "6.0.0", + "form-urlencoded": "7.0.0", + "formatters": "7.0.0", + "framer-motion": "1.0.1", + "free": "7.1.0", + "freeap": "7.0.0", + "freer-free": "0.0.1", + "freet": "7.0.0", + "functions": "6.0.0", + "functor1": "3.0.0", + "functors": "5.0.0", + "fuzzy": "0.4.0", + "gen": "4.0.0", + "generate-values": "1.0.1", + "generic-router": "0.0.1", + "geojson": "0.0.5", + "geometria": "2.2.0", + "gojs": "0.1.1", + "grain": "3.0.0", + "grain-router": "3.0.0", + "grain-virtualized": "3.0.0", + "graphs": "8.1.0", + "group": "4.1.1", + "halogen": "7.0.0", + "halogen-bootstrap5": "5.3.2", + "halogen-canvas": "1.0.0", + "halogen-css": "10.0.0", + "halogen-echarts-simple": "0.0.4", + "halogen-formless": "4.0.3", + "halogen-helix": "1.0.1", + "halogen-hooks": "0.6.3", + "halogen-hooks-extra": "0.9.0", + "halogen-infinite-scroll": "1.1.0", + "halogen-store": "0.5.4", + "halogen-storybook": "2.0.0", + "halogen-subscriptions": "2.0.0", + "halogen-svg-elems": "8.0.0", + "halogen-typewriter": "1.0.4", + "halogen-vdom": "8.0.0", + "halogen-vdom-string-renderer": "0.5.0", + "halogen-xterm": "2.0.0", + "heckin": "2.0.1", + "heterogeneous": "0.6.0", + "homogeneous": "0.4.0", + "http-methods": "6.0.0", + "httpurple": "4.0.0", + "huffman": "0.4.0", + "humdrum": "0.0.1", + "hyrule": "2.3.8", + "identity": "6.0.0", + "identy": "4.0.1", + "indexed-db": "1.0.0", + "indexed-monad": "3.0.0", + "int64": "3.0.0", + "integers": "6.0.0", + "interpolate": "5.0.2", + "intersection-observer": "1.0.1", + "invariant": "6.0.0", + "jarilo": "1.0.1", + "jelly": "0.10.0", + "jelly-router": "0.3.0", + "jelly-signal": "0.4.0", + "jest": "1.0.0", + "js-abort-controller": "1.0.0", + "js-bigints": "2.2.1", + "js-date": "8.0.0", + "js-fetch": "0.2.1", + "js-fileio": "3.0.0", + "js-intl": "1.0.4", + "js-iterators": "0.1.1", + "js-maps": "0.1.2", + "js-promise": "1.0.0", + "js-promise-aff": "1.0.0", + "js-timers": "6.1.0", + "js-uri": "3.1.0", + "json": "1.1.0", + "json-codecs": "5.0.0", + "justifill": "0.5.0", + "jwt": "0.0.9", + "labeled-data": "0.2.0", + "language-cst-parser": "0.14.0", + "lazy": "6.0.0", + "lazy-joe": "1.0.0", + "lcg": "4.0.0", + "leibniz": "5.0.0", + "leveldb": "1.0.1", + "liminal": "1.0.1", + "linalg": "6.0.0", + "lists": "7.0.0", + "literals": "1.0.2", + "logging": "3.0.0", + "logging-journald": "0.4.0", + "lumi-components": "18.0.0", + "machines": "7.0.0", + "maps-eager": "0.5.0", + "marionette": "1.0.0", + "marionette-react-basic-hooks": "0.1.1", + "marked": "0.1.0", + "matrices": "5.0.1", + "matryoshka": "1.0.0", + "maybe": "6.0.0", + "media-types": "6.0.0", + "meowclient": "1.0.0", + "midi": "4.0.0", + "milkis": "9.0.0", + "minibench": "4.0.1", + "mmorph": "7.0.0", + "monad-control": "5.0.0", + "monad-logger": "1.3.1", + "monad-loops": "0.5.0", + "monad-unlift": "1.0.1", + "monoid-extras": "0.0.1", + "monoidal": "0.16.0", + "morello": "0.4.0", + "mote": "3.0.0", + "motsunabe": "2.0.0", + "mvc": "0.0.1", + "mysql": "6.0.1", + "n3": "0.1.0", + "nano-id": "1.1.0", + "nanoid": "0.1.0", + "naturals": "3.0.0", + "nested-functor": "0.2.1", + "newtype": "5.0.0", + "nextjs": "0.1.1", + "nextui": "0.2.0", + "node-buffer": "9.0.0", + "node-child-process": "11.1.0", + "node-event-emitter": "3.0.0", + "node-execa": "5.0.0", + "node-fs": "9.2.0", + "node-glob-basic": "1.3.0", + "node-http": "9.1.0", + "node-http2": "1.1.1", + "node-human-signals": "1.0.0", + "node-net": "5.1.0", + "node-os": "5.1.0", + "node-path": "5.0.0", + "node-process": "11.2.0", + "node-readline": "8.1.1", + "node-sqlite3": "8.0.0", + "node-stream-pipes": "2.1.6", + "node-streams": "9.0.0", + "node-tls": "0.3.1", + "node-url": "7.0.1", + "node-zlib": "0.4.0", + "nonempty": "7.0.0", + "now": "6.0.0", + "npm-package-json": "2.0.0", + "nullable": "6.0.0", + "numberfield": "0.2.2", + "numbers": "9.0.1", + "oak": "3.1.1", + "oak-debug": "1.2.2", + "object-maps": "0.3.0", + "ocarina": "1.5.4", + "oooooooooorrrrrrrmm-lib": "0.0.1", + "open-colors-scales-and-schemes": "1.0.0", + "open-folds": "6.4.0", + "open-foreign-generic": "11.0.3", + "open-memoize": "6.2.0", + "open-mkdirp-aff": "1.2.0", + "open-pairing": "6.2.0", + "open-smolder": "12.0.2", + "options": "7.0.0", + "optparse": "5.0.1", + "ordered-collections": "3.2.0", + "ordered-set": "0.4.0", + "orders": "6.0.0", + "owoify": "1.2.0", + "pairs": "9.0.1", + "parallel": "7.0.0", + "parsing": "10.2.0", + "parsing-dataview": "3.2.4", + "partial": "4.0.0", + "pathy": "9.0.0", + "pha": "0.13.0", + "phaser": "0.7.0", + "phylio": "1.1.2", + "pipes": "8.0.0", + "pirates-charm": "0.0.1", + "pmock": "0.9.0", + "point-free": "1.0.0", + "pointed-list": "0.5.1", + "polymorphic-vectors": "4.0.0", + "posix-types": "6.0.0", + "postgresql": "2.0.19", + "precise": "6.0.0", + "precise-datetime": "7.0.0", + "prelude": "6.0.1", + "prettier-printer": "3.0.0", + "priority-queue": "0.1.2", + "profunctor": "6.0.1", + "profunctor-lenses": "8.0.0", + "protobuf": "4.3.0", + "psa-utils": "8.0.0", + "psci-support": "6.0.0", + "punycode": "1.0.0", + "qualified-do": "2.2.0", + "quantities": "12.2.0", + "quickcheck": "8.0.1", + "quickcheck-combinators": "0.1.3", + "quickcheck-laws": "7.0.0", + "quickcheck-utf8": "0.0.0", + "random": "6.0.0", + "rationals": "6.0.0", + "rdf": "0.1.0", + "react": "11.0.0", + "react-aria": "0.2.0", + "react-basic": "17.0.0", + "react-basic-classic": "3.0.0", + "react-basic-dnd": "10.1.0", + "react-basic-dom": "6.1.0", + "react-basic-dom-beta": "0.1.1", + "react-basic-emotion": "7.1.0", + "react-basic-hooks": "8.2.0", + "react-basic-storybook": "2.0.0", + "react-dom": "8.0.0", + "react-halo": "3.0.0", + "react-icons": "1.1.5", + "react-markdown": "0.1.0", + "react-testing-library": "4.0.1", + "react-virtuoso": "1.0.0", + "reactix": "0.6.1", + "read": "1.0.1", + "recharts": "1.1.0", + "record": "4.0.0", + "record-extra": "5.0.1", + "record-ptional-fields": "0.1.2", + "record-studio": "1.0.4", + "refs": "6.0.0", + "remotedata": "5.0.1", + "repr": "0.5.0", + "resize-observer": "1.0.0", + "resource": "2.0.1", + "resourcet": "1.0.0", + "result": "1.0.3", + "return": "0.2.0", + "ring-modules": "5.0.1", + "rito": "0.3.4", + "roman": "0.4.0", + "rough-notation": "1.0.2", + "routing": "11.0.0", + "routing-duplex": "0.7.0", + "run": "5.0.0", + "safe-coerce": "2.0.0", + "safely": "4.0.1", + "school-of-music": "1.3.0", + "selection-foldable": "0.2.0", + "selective-functors": "1.0.1", + "semirings": "7.0.0", + "signal": "13.0.0", + "simple-emitter": "3.0.1", + "simple-i18n": "2.0.1", + "simple-json": "9.0.0", + "simple-json-generics": "0.2.1", + "simple-ulid": "3.0.0", + "sized-matrices": "1.0.0", + "sized-vectors": "5.0.2", + "slug": "3.1.0", + "small-ffi": "4.0.1", + "soundfonts": "4.1.0", + "sparse-matrices": "2.0.1", + "sparse-polynomials": "3.0.1", + "spec": "8.1.0", + "spec-discovery": "8.4.0", + "spec-mocha": "5.1.1", + "spec-node": "0.0.2", + "spec-quickcheck": "5.0.2", + "spec-reporter-xunit": "0.7.1", + "splitmix": "2.1.0", + "ssrs": "1.0.0", + "st": "6.2.0", + "statistics": "0.3.2", + "strictlypositiveint": "1.0.1", + "string-parsers": "8.0.0", + "strings": "6.0.1", + "strings-extra": "4.0.0", + "stringutils": "0.0.12", + "substitute": "0.2.3", + "supply": "0.2.0", + "svg-parser": "3.0.0", + "systemd-journald": "0.3.0", + "tagged": "4.0.2", + "tailrec": "6.1.0", + "tecton": "0.2.1", + "tecton-halogen": "0.2.0", + "test-unit": "17.0.0", + "thermite": "6.3.1", + "thermite-dom": "0.3.1", + "these": "6.0.0", + "threading": "0.0.3", + "tldr": "0.0.0", + "toestand": "0.9.0", + "transformation-matrix": "1.0.1", + "transformers": "6.1.0", + "tree-rose": "4.0.2", + "ts-bridge": "4.0.0", + "tuples": "7.0.0", + "two-or-more": "1.0.0", + "type-equality": "4.0.1", + "typedenv": "2.0.1", + "typelevel": "6.0.0", + "typelevel-lists": "2.1.0", + "typelevel-peano": "1.0.1", + "typelevel-prelude": "7.0.0", + "typelevel-regex": "0.0.3", + "typelevel-rows": "0.1.0", + "typisch": "0.4.0", + "uint": "7.0.0", + "ulid": "3.0.1", + "uncurried-transformers": "1.1.0", + "undefined": "2.0.0", + "undefined-is-not-a-problem": "1.1.0", + "unfoldable": "6.0.0", + "unicode": "6.0.0", + "unique": "0.6.1", + "unlift": "1.0.1", + "unordered-collections": "3.1.0", + "unsafe-coerce": "6.0.0", + "unsafe-reference": "5.0.0", + "untagged-to-tagged": "0.1.4", + "untagged-union": "1.0.0", + "uri": "9.0.0", + "url-immutable": "1.0.0", + "uuid": "9.0.0", + "uuidv4": "1.0.0", + "validation": "6.0.0", + "variant": "8.0.0", + "variant-encodings": "2.0.0", + "vectorfield": "1.0.1", + "vectors": "2.1.0", + "versions": "7.0.0", + "visx": "0.0.2", + "web-clipboard": "6.0.0", + "web-cssom": "2.0.0", + "web-cssom-view": "0.1.0", + "web-dom": "6.0.0", + "web-dom-parser": "8.0.0", + "web-dom-xpath": "3.0.0", + "web-encoding": "3.0.0", + "web-events": "4.0.0", + "web-fetch": "4.0.1", + "web-file": "4.0.0", + "web-geometry": "0.1.0", + "web-html": "4.1.0", + "web-pointerevents": "2.0.0", + "web-proletarian": "1.0.0", + "web-promise": "3.2.0", + "web-resize-observer": "2.1.0", + "web-router": "1.0.0", + "web-socket": "4.0.0", + "web-storage": "5.0.0", + "web-streams": "4.0.0", + "web-touchevents": "4.0.0", + "web-uievents": "5.0.0", + "web-url": "2.0.0", + "web-workers": "1.1.0", + "web-xhr": "5.0.1", + "webextension-polyfill": "0.1.0", + "webgpu": "0.0.1", + "which": "2.0.0", + "xterm": "1.0.0", + "yoga-fetch": "1.0.1", + "yoga-json": "5.1.0", + "yoga-om": "0.1.0", + "yoga-postgres": "6.0.0", + "yoga-tree": "1.0.0", + "z3": "0.0.2", + "zipperarray": "2.0.0" + } + }, + "extra_packages": {} + }, + "packages": { + "arrays": { + "type": "registry", + "version": "7.3.0", + "integrity": "sha256-tmcklBlc/muUtUfr9RapdCPwnlQeB3aSrC4dK85gQlc=", + "dependencies": [ + "bifunctors", + "control", + "foldable-traversable", + "functions", + "maybe", + "nonempty", + "partial", + "prelude", + "safe-coerce", + "st", + "tailrec", + "tuples", + "unfoldable", + "unsafe-coerce" + ] + }, + "bifunctors": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-/gZwC9YhNxZNQpnHa5BIYerCGM2jeX9ukZiEvYxm5Nw=", + "dependencies": [ + "const", + "either", + "newtype", + "prelude", + "tuples" + ] + }, + "console": { + "type": "registry", + "version": "6.1.0", + "integrity": "sha256-CxmAzjgyuGDmt9FZW51VhV6rBPwR6o0YeKUzA9rSzcM=", + "dependencies": [ + "effect", + "prelude" + ] + }, + "const": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-tNrxDW8D8H4jdHE2HiPzpLy08zkzJMmGHdRqt5BQuTc=", + "dependencies": [ + "invariant", + "newtype", + "prelude" + ] + }, + "contravariant": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-TP+ooAp3vvmdjfQsQJSichF5B4BPDHp3wAJoWchip6c=", + "dependencies": [ + "const", + "either", + "newtype", + "prelude", + "tuples" + ] + }, + "control": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-sH7Pg9E96JCPF9PIA6oQ8+BjTyO/BH1ZuE/bOcyj4Jk=", + "dependencies": [ + "newtype", + "prelude" + ] + }, + "distributive": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-HTDdmEnzigMl+02SJB88j+gAXDx9VKsbvR4MJGDPbOQ=", + "dependencies": [ + "identity", + "newtype", + "prelude", + "tuples", + "type-equality" + ] + }, + "effect": { + "type": "registry", + "version": "4.0.0", + "integrity": "sha256-eBtZu+HZcMa5HilvI6kaDyVX3ji8p0W9MGKy2K4T6+M=", + "dependencies": [ + "prelude" + ] + }, + "either": { + "type": "registry", + "version": "6.1.0", + "integrity": "sha256-6hgTPisnMWVwQivOu2PKYcH8uqjEOOqDyaDQVUchTpY=", + "dependencies": [ + "control", + "invariant", + "maybe", + "prelude" + ] + }, + "enums": { + "type": "registry", + "version": "6.0.1", + "integrity": "sha256-HWaD73JFLorc4A6trKIRUeDMdzE+GpkJaEOM1nTNkC8=", + "dependencies": [ + "control", + "either", + "gen", + "maybe", + "newtype", + "nonempty", + "partial", + "prelude", + "tuples", + "unfoldable" + ] + }, + "exceptions": { + "type": "registry", + "version": "6.1.0", + "integrity": "sha256-K0T89IHtF3vBY7eSAO7eDOqSb2J9kZGAcDN5+IKsF8E=", + "dependencies": [ + "effect", + "either", + "maybe", + "prelude" + ] + }, + "exists": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-A0JQHpTfo1dNOj9U5/Fd3xndlRSE0g2IQWOGor2yXn8=", + "dependencies": [ + "unsafe-coerce" + ] + }, + "foldable-traversable": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-fLeqRYM4jUrZD5H4WqcwUgzU7XfYkzO4zhgtNc3jcWM=", + "dependencies": [ + "bifunctors", + "const", + "control", + "either", + "functors", + "identity", + "maybe", + "newtype", + "orders", + "prelude", + "tuples" + ] + }, + "functions": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-adMyJNEnhGde2unHHAP79gPtlNjNqzgLB8arEOn9hLI=", + "dependencies": [ + "prelude" + ] + }, + "functors": { + "type": "registry", + "version": "5.0.0", + "integrity": "sha256-zfPWWYisbD84MqwpJSZFlvM6v86McM68ob8p9s27ywU=", + "dependencies": [ + "bifunctors", + "const", + "contravariant", + "control", + "distributive", + "either", + "invariant", + "maybe", + "newtype", + "prelude", + "profunctor", + "tuples", + "unsafe-coerce" + ] + }, + "gen": { + "type": "registry", + "version": "4.0.0", + "integrity": "sha256-f7yzAXWwr+xnaqEOcvyO3ezKdoes8+WXWdXIHDBCAPI=", + "dependencies": [ + "either", + "foldable-traversable", + "identity", + "maybe", + "newtype", + "nonempty", + "prelude", + "tailrec", + "tuples", + "unfoldable" + ] + }, + "heterogeneous": { + "type": "registry", + "version": "0.6.0", + "integrity": "sha256-cfNYSK6yYmjTrkzk95Otpv6TUUkeBreexwqG/tBvUyg=", + "dependencies": [ + "either", + "functors", + "prelude", + "record", + "tuples", + "variant" + ] + }, + "identity": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-4wY0XZbAksjY6UAg99WkuKyJlQlWAfTi2ssadH0wVMY=", + "dependencies": [ + "control", + "invariant", + "newtype", + "prelude" + ] + }, + "integers": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-sf+sK26R1hzwl3NhXR7WAu9zCDjQnfoXwcyGoseX158=", + "dependencies": [ + "maybe", + "numbers", + "prelude" + ] + }, + "invariant": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-RGWWyYrz0Hs1KjPDA+87Kia67ZFBhfJ5lMGOMCEFoLo=", + "dependencies": [ + "control", + "prelude" + ] + }, + "lazy": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-lMsfFOnlqfe4KzRRiW8ot5ge6HtcU3Eyh2XkXcP5IgU=", + "dependencies": [ + "control", + "foldable-traversable", + "invariant", + "prelude" + ] + }, + "lcg": { + "type": "registry", + "version": "4.0.0", + "integrity": "sha256-h7ME5cthLfbgJOJdsZcSfFpwXsx4rf8YmhebU+3iSYg=", + "dependencies": [ + "effect", + "integers", + "maybe", + "partial", + "prelude", + "random" + ] + }, + "lists": { + "type": "registry", + "version": "7.0.0", + "integrity": "sha256-EKF15qYqucuXP2lT/xPxhqy58f0FFT6KHdIB/yBOayI=", + "dependencies": [ + "bifunctors", + "control", + "foldable-traversable", + "lazy", + "maybe", + "newtype", + "nonempty", + "partial", + "prelude", + "tailrec", + "tuples", + "unfoldable" + ] + }, + "maybe": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-5cCIb0wPwbat2PRkQhUeZO0jcAmf8jCt2qE0wbC3v2Q=", + "dependencies": [ + "control", + "invariant", + "newtype", + "prelude" + ] + }, + "newtype": { + "type": "registry", + "version": "5.0.0", + "integrity": "sha256-gdrQu8oGe9eZE6L3wOI8ql/igOg+zEGB5ITh2g+uttw=", + "dependencies": [ + "prelude", + "safe-coerce" + ] + }, + "nonempty": { + "type": "registry", + "version": "7.0.0", + "integrity": "sha256-54ablJZUHGvvlTJzi3oXyPCuvY6zsrWJuH/dMJ/MFLs=", + "dependencies": [ + "control", + "foldable-traversable", + "maybe", + "prelude", + "tuples", + "unfoldable" + ] + }, + "numbers": { + "type": "registry", + "version": "9.0.1", + "integrity": "sha256-/9M6aeMDBdB4cwYDeJvLFprAHZ49EbtKQLIJsneXLIk=", + "dependencies": [ + "functions", + "maybe" + ] + }, + "ordered-collections": { + "type": "registry", + "version": "3.2.0", + "integrity": "sha256-o9jqsj5rpJmMdoe/zyufWHFjYYFTTsJpgcuCnqCO6PM=", + "dependencies": [ + "arrays", + "foldable-traversable", + "gen", + "lists", + "maybe", + "partial", + "prelude", + "st", + "tailrec", + "tuples", + "unfoldable" + ] + }, + "orders": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-nBA0g3/ai0euH8q9pSbGqk53W2q6agm/dECZTHcoink=", + "dependencies": [ + "newtype", + "prelude" + ] + }, + "parallel": { + "type": "registry", + "version": "7.0.0", + "integrity": "sha256-gUC9i4Txnx9K9RcMLsjujbwZz6BB1bnE2MLvw4GIw5o=", + "dependencies": [ + "control", + "effect", + "either", + "foldable-traversable", + "functors", + "maybe", + "newtype", + "prelude", + "profunctor", + "refs", + "transformers" + ] + }, + "partial": { + "type": "registry", + "version": "4.0.0", + "integrity": "sha256-fwXerld6Xw1VkReh8yeQsdtLVrjfGiVuC5bA1Wyo/J4=", + "dependencies": [] + }, + "prelude": { + "type": "registry", + "version": "6.0.1", + "integrity": "sha256-o8p6SLYmVPqzXZhQFd2hGAWEwBoXl1swxLG/scpJ0V0=", + "dependencies": [] + }, + "profunctor": { + "type": "registry", + "version": "6.0.1", + "integrity": "sha256-E58hSYdJvF2Qjf9dnWLPlJKh2Z2fLfFLkQoYi16vsFk=", + "dependencies": [ + "control", + "distributive", + "either", + "exists", + "invariant", + "newtype", + "prelude", + "tuples" + ] + }, + "quickcheck": { + "type": "registry", + "version": "8.0.1", + "integrity": "sha256-ZvpccKQCvgslTXZCNmpYW4bUsFzhZd/kQUr2WmxFTGY=", + "dependencies": [ + "arrays", + "console", + "control", + "effect", + "either", + "enums", + "exceptions", + "foldable-traversable", + "gen", + "identity", + "integers", + "lazy", + "lcg", + "lists", + "maybe", + "newtype", + "nonempty", + "numbers", + "partial", + "prelude", + "record", + "st", + "strings", + "tailrec", + "transformers", + "tuples", + "unfoldable" + ] + }, + "quickcheck-laws": { + "type": "registry", + "version": "7.0.0", + "integrity": "sha256-rnzVTiDnymzYkvnhI8EvPwrmO8LgcTnrMTuiI172Tkc=", + "dependencies": [ + "enums", + "quickcheck" + ] + }, + "random": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-CJ611a35MPCE7XQMp0rdC6MCn76znlhisiCRgboAG+Q=", + "dependencies": [ + "effect", + "integers" + ] + }, + "record": { + "type": "registry", + "version": "4.0.0", + "integrity": "sha256-Za5U85bTRJEfGK5Sk4hM41oXy84YQI0I8TL3WUn1Qzg=", + "dependencies": [ + "functions", + "prelude", + "unsafe-coerce" + ] + }, + "refs": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-Vgwne7jIbD3ZMoLNNETLT8Litw6lIYo3MfYNdtYWj9s=", + "dependencies": [ + "effect", + "prelude" + ] + }, + "safe-coerce": { + "type": "registry", + "version": "2.0.0", + "integrity": "sha256-a1ibQkiUcbODbLE/WAq7Ttbbh9ex+x33VCQ7GngKudU=", + "dependencies": [ + "unsafe-coerce" + ] + }, + "st": { + "type": "registry", + "version": "6.2.0", + "integrity": "sha256-z9X0WsOUlPwNx9GlCC+YccCyz8MejC8Wb0C4+9fiBRY=", + "dependencies": [ + "partial", + "prelude", + "tailrec", + "unsafe-coerce" + ] + }, + "strings": { + "type": "registry", + "version": "6.0.1", + "integrity": "sha256-WssD3DbX4OPzxSdjvRMX0yvc9+pS7n5gyPv5I2Trb7k=", + "dependencies": [ + "arrays", + "control", + "either", + "enums", + "foldable-traversable", + "gen", + "integers", + "maybe", + "newtype", + "nonempty", + "partial", + "prelude", + "tailrec", + "tuples", + "unfoldable", + "unsafe-coerce" + ] + }, + "tailrec": { + "type": "registry", + "version": "6.1.0", + "integrity": "sha256-Xx19ECVDRrDWpz9D2GxQHHV89vd61dnXxQm0IcYQHGk=", + "dependencies": [ + "bifunctors", + "effect", + "either", + "identity", + "maybe", + "partial", + "prelude", + "refs" + ] + }, + "transformers": { + "type": "registry", + "version": "6.1.0", + "integrity": "sha256-3Bm+Z6tsC/paG888XkywDngJ2JMos+JfOhRlkVfb7gI=", + "dependencies": [ + "control", + "distributive", + "effect", + "either", + "exceptions", + "foldable-traversable", + "identity", + "lazy", + "maybe", + "newtype", + "prelude", + "st", + "tailrec", + "tuples", + "unfoldable" + ] + }, + "tuples": { + "type": "registry", + "version": "7.0.0", + "integrity": "sha256-1rXgTomes9105BjgXqIw0FL6Fz1lqqUTLWOumhWec1M=", + "dependencies": [ + "control", + "invariant", + "prelude" + ] + }, + "type-equality": { + "type": "registry", + "version": "4.0.1", + "integrity": "sha256-Hs9D6Y71zFi/b+qu5NSbuadUQXe5iv5iWx0226vOHUw=", + "dependencies": [] + }, + "typelevel-prelude": { + "type": "registry", + "version": "7.0.0", + "integrity": "sha256-uFF2ph+vHcQpfPuPf2a3ukJDFmLhApmkpTMviHIWgJM=", + "dependencies": [ + "prelude", + "type-equality" + ] + }, + "unfoldable": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-JtikvJdktRap7vr/K4ITlxUX1QexpnqBq0G/InLr6eg=", + "dependencies": [ + "foldable-traversable", + "maybe", + "partial", + "prelude", + "tuples" + ] + }, + "unsafe-coerce": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-IqIYW4Vkevn8sI+6aUwRGvd87tVL36BBeOr0cGAE7t0=", + "dependencies": [] + }, + "validation": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-kfFailaIW4spGxbRk4261z/RGT0Sb7Dx5f3qihy0MTw=", + "dependencies": [ + "bifunctors", + "control", + "either", + "foldable-traversable", + "newtype", + "prelude" + ] + }, + "variant": { + "type": "registry", + "version": "8.0.0", + "integrity": "sha256-SR//zQDg2dnbB8ZHslcxieUkCeNlbMToapvmh9onTtw=", + "dependencies": [ + "enums", + "lists", + "maybe", + "partial", + "prelude", + "record", + "tuples", + "unsafe-coerce" + ] + } + } +} diff --git a/spago.yaml b/spago.yaml new file mode 100644 index 0000000..7af3b6f --- /dev/null +++ b/spago.yaml @@ -0,0 +1,38 @@ +package: + dependencies: + - bifunctors + - control + - either + - functors + - heterogeneous + - identity + - invariant + - lists + - maybe + - newtype + - ordered-collections + - parallel + - partial + - prelude + - profunctor + - record + - transformers + - tuples + - type-equality + - typelevel-prelude + - unsafe-coerce + - validation + - variant + name: polyform + test: + main: Test.Main + dependencies: + - arrays + - effect + - enums + - quickcheck + - quickcheck-laws +workspace: + extraPackages: {} + packageSet: + registry: 60.4.0 diff --git a/src/Polyform/Dual/Variant.js b/src/Polyform/Dual/Variant.js index ac58926..3a6106f 100644 --- a/src/Polyform/Dual/Variant.js +++ b/src/Polyform/Dual/Variant.js @@ -1,5 +1,5 @@ "use strict"; -exports.unsafeStringify = function(a) { +export function unsafeStringify(a) { return JSON.stringify(a); } diff --git a/test/Main.purs b/test/Test/Main.purs similarity index 100% rename from test/Main.purs rename to test/Test/Main.purs diff --git a/test/Polyform/Reporter.purs b/test/Test/Polyform/Reporter.purs similarity index 93% rename from test/Polyform/Reporter.purs rename to test/Test/Polyform/Reporter.purs index a067410..9e9885d 100644 --- a/test/Polyform/Reporter.purs +++ b/test/Test/Polyform/Reporter.purs @@ -21,10 +21,10 @@ import Test.QuickCheck.Laws (A, B, C, checkLaws) import Test.QuickCheck.Laws.Control as Control import Test.QuickCheck.Laws.Data as Data import Type.Prelude (Proxy(..)) -import Type.Proxy (Proxy2(..), Proxy3(..)) import Unsafe.Coerce (unsafeCoerce) newtype AReporter e i o = AReporter (Reporter Identity e i o) + instance eqAReporter ∷ (Eq o, Eq e, Bounded i, Enum i) ⇒ Eq (AReporter e i o) where eq (AReporter r1) (AReporter r2) = let @@ -36,6 +36,7 @@ fromEither ∷ ∀ a e. Either e a → R e a fromEither = unsafeCoerce newtype Ar e i o = Ar (i → Identity (R e o)) + instance arbitraryA ∷ (Arbitrary e, Coarbitrary i, Arbitrary o) ⇒ Arbitrary (AReporter e i o) where arbitrary = -- | Type annotation just for readability @@ -73,6 +74,6 @@ suite = checkLaws "Reporter" do -- Control.checkMonadZero prx2Array -- Control.checkMonadPlus prx2Array where - prxReporter = Proxy ∷ Proxy (AReporter A B C) - prx2Reporter = Proxy2 ∷ Proxy2 (AReporter A B) - prx3Reporter = Proxy3 ∷ Proxy3 (AReporter A) + prxReporter = Proxy ∷ _ (AReporter A B C) + prx2Reporter = Proxy ∷ _ (AReporter A B) + prx3Reporter = Proxy ∷ _ (AReporter A) diff --git a/test/Polyform/Validator.purs b/test/Test/Polyform/Validator.purs similarity index 93% rename from test/Polyform/Validator.purs rename to test/Test/Polyform/Validator.purs index c94f900..e6469d4 100644 --- a/test/Polyform/Validator.purs +++ b/test/Test/Polyform/Validator.purs @@ -18,10 +18,11 @@ import Test.QuickCheck.Gen (Gen) import Test.QuickCheck.Laws (A, B, C, checkLaws) import Test.QuickCheck.Laws.Control as Control import Test.QuickCheck.Laws.Data as Data -import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..)) +import Type.Proxy (Proxy(..)) import Unsafe.Coerce (unsafeCoerce) newtype AValidator e i o = AValidator (Validator Identity e i o) + instance eqAValidator ∷ (Eq o, Eq e, Bounded i, Enum i) ⇒ Eq (AValidator e i o) where eq (AValidator (Validator (Star v1))) (AValidator (Validator (Star v2))) = let @@ -33,6 +34,7 @@ fromEither ∷ ∀ a e. Either e a → V e a fromEither = unsafeCoerce newtype Ar e i o = Ar (i → Identity (V e o)) + instance arbitraryA ∷ (Arbitrary e, Coarbitrary i, Arbitrary o) ⇒ Arbitrary (AValidator e i o) where arbitrary = -- | Type annotation just for readability @@ -71,6 +73,6 @@ suite = checkLaws "Validator" do -- Control.checkMonadZero prx2Array -- Control.checkMonadPlus prx2Array where - prxValidator = Proxy ∷ Proxy (AValidator A B C) - prx2Validator = Proxy2 ∷ Proxy2 (AValidator A B) - prx3Validator = Proxy3 ∷ Proxy3 (AValidator A) + prxValidator = Proxy ∷ _ (AValidator A B C) + prx2Validator = Proxy ∷ _ (AValidator A B) + prx3Validator = Proxy ∷ _ (AValidator A) From 6239ed924f19d26004ba776eeb105d8ba1089020 Mon Sep 17 00:00:00 2001 From: Serhii Khoma Date: Wed, 9 Oct 2024 18:27:00 +0700 Subject: [PATCH 2/2] purs-tidy format-in-place src/**/*.purs test/**/*.purs --- src/Polyform.purs | 3 +- src/Polyform/Dual.purs | 30 +++++++++---------- src/Polyform/Dual/Generic/Sum.purs | 26 ++++++++-------- src/Polyform/Dual/Generic/Variant.purs | 32 ++++++++++---------- src/Polyform/Dual/Record.purs | 12 ++++---- src/Polyform/Dual/Variant.purs | 10 +++---- src/Polyform/Exceptor.purs | 10 +++---- src/Polyform/Reporter.purs | 31 +++++++++---------- src/Polyform/Reporter/Dual.purs | 38 ++++++++++++------------ src/Polyform/Tokenized.purs | 9 +++--- src/Polyform/Tokenized/Dual.purs | 18 +++++------ src/Polyform/Tokenized/Validator.purs | 3 +- src/Polyform/Validator.purs | 21 ++++++++----- src/Polyform/Validator/Dual.purs | 6 ++-- src/Polyform/Validator/Dual/Generic.purs | 8 +++-- src/Polyform/Validator/Dual/Pure.purs | 4 +-- src/Polyform/Validator/Par.purs | 9 +++--- src/Polyform/Validator/Record.purs | 25 +++++++++------- 18 files changed, 150 insertions(+), 145 deletions(-) diff --git a/src/Polyform.purs b/src/Polyform.purs index 8e562c2..cf97f2a 100644 --- a/src/Polyform.purs +++ b/src/Polyform.purs @@ -2,8 +2,7 @@ module Polyform ( module Validator , module Reporter , module Dual - ) - where + ) where import Polyform.Validator (Validator(..)) as Validator import Polyform.Reporter (Reporter(..)) as Reporter diff --git a/src/Polyform/Dual.purs b/src/Polyform/Dual.purs index 516b764..991db50 100644 --- a/src/Polyform/Dual.purs +++ b/src/Polyform/Dual.purs @@ -24,8 +24,7 @@ import Data.Profunctor (class Profunctor, dimap, lcmap) -- | They "join" in `Dual` type which wraps `DualD` a few -- | lines below. data DualD :: (Type -> Type -> Type) -> (Type -> Type) -> Type -> Type -> Type -> Type -data DualD p s i o o' - = DualD (p i o') (o → s i) +data DualD p s i o o' = DualD (p i o') (o → s i) derive instance functorDualD ∷ (Functor (p i)) ⇒ Functor (DualD p s i o) @@ -51,19 +50,18 @@ instance lazyDualD ∷ (Lazy (p i o')) ⇒ Lazy (DualD p s i o o') where (defer \_ → let DualD _ ser = f unit in ser) -- | `Dual` turns `DualD` into `Invariant` (it differs from `Join`). -newtype Dual p s i o - = Dual (DualD p s i o o) +newtype Dual p s i o = Dual (DualD p s i o o) derive instance newtypeDual ∷ Newtype (Dual p s i o) _ instance invariantFunctor ∷ Functor (p i) ⇒ Invariant (Dual p s i) where imap f g (Dual d) = Dual (dimap g f d) -dual ∷ - ∀ i o p s. - (p i o) → - (o → s i) → - Dual p s i o +dual + ∷ ∀ i o p s + . (p i o) + → (o → s i) + → Dual p s i o dual prs = Dual <<< DualD prs dual' ∷ ∀ i p s. Applicative s ⇒ p i i → Dual p s i i @@ -119,11 +117,11 @@ instance lazyDual ∷ (Lazy (p i o)) ⇒ Lazy (Dual p s i o) where -- | Of course these two steps can be handled by some generic layer. infixl 5 diverge as ~ -diverge ∷ - ∀ i o o' p s. - Functor (p i) ⇒ - Profunctor p ⇒ - (o' → o) → - Dual p s i o → - DualD p s i o' o +diverge + ∷ ∀ i o o' p s + . Functor (p i) + ⇒ Profunctor p + ⇒ (o' → o) + → Dual p s i o + → DualD p s i o' o diverge f = lcmap f <<< unwrap diff --git a/src/Polyform/Dual/Generic/Sum.purs b/src/Polyform/Dual/Generic/Sum.purs index daea187..6b8b9cd 100644 --- a/src/Polyform/Dual/Generic/Sum.purs +++ b/src/Polyform/Dual/Generic/Sum.purs @@ -43,13 +43,13 @@ instance gDualConstructor :: , GDualCtr p s i a b ) => GDualSum p s i (Constructor sym b) r where - gDual pre r = dual prs' ser' - where - _s = Proxy ∷ Proxy sym - Dual (DualD prs ser) = pre _s $ - (gDualCtr ∷ Dual p s i a → Dual p s i b) (Record.get _s r) - ser' (Constructor a) = ser a - prs' = Constructor <$> prs + gDual pre r = dual prs' ser' + where + _s = Proxy ∷ Proxy sym + Dual (DualD prs ser) = pre _s $ + (gDualCtr ∷ Dual p s i a → Dual p s i b) (Record.get _s r) + ser' (Constructor a) = ser a + prs' = Constructor <$> prs class GDualCtr ∷ (Type -> Type -> Type) -> (Type -> Type) -> Type -> Type -> Type -> Constraint class GDualCtr p s i o o' | o → o' where @@ -58,21 +58,19 @@ class GDualCtr p s i o o' | o → o' where instance gDualProduct :: GDualCtr p s i (Product a b) (Product a b) where gDualCtr = identity -else -instance gDualNoArguments :: +else instance gDualNoArguments :: GDualCtr p s i NoArguments NoArguments where gDualCtr = identity -else -instance gDualArgument :: +else instance gDualArgument :: GDualCtr p s i (Argument a) (Argument a) where gDualCtr = identity -else -instance gDualAll :: +else instance gDualAll :: GDualCtr p s i a (Argument a) where gDualCtr (Dual (DualD prs ser)) = dual (Argument <$> prs) (\(Argument a) → ser a) -sum ∷ ∀ a i p rep r s +sum + ∷ ∀ a i p rep r s . Generic a rep ⇒ GDualSum p s i rep r ⇒ Functor (p i) diff --git a/src/Polyform/Dual/Generic/Variant.purs b/src/Polyform/Dual/Generic/Variant.purs index bd8ed56..6492b10 100644 --- a/src/Polyform/Dual/Generic/Variant.purs +++ b/src/Polyform/Dual/Generic/Variant.purs @@ -28,16 +28,17 @@ instance gDualVariantLast ∷ ( IsSymbol l , Row.Cons l a () v , Row.Cons l (Dual p s i a) () d - ) ⇒ GDualVariant p s i (Cons l (Dual p s i a) Nil) d v where + ) ⇒ + GDualVariant p s i (Cons l (Dual p s i a) Nil) d v where gDualV _ pre duals = d where - _l = Proxy ∷ Proxy l + _l = Proxy ∷ Proxy l - Dual (DualD fieldPrs fieldSer) = pre _l (Record.get _l duals) - prs = (inj _l <$> fieldPrs) - ser = case_ # on _l fieldSer + Dual (DualD fieldPrs fieldSer) = pre _l (Record.get _l duals) + prs = (inj _l <$> fieldPrs) + ser = case_ # on _l fieldSer - d = dual prs ser + d = dual prs ser else instance gDualVariantCons ∷ ( IsSymbol l @@ -47,20 +48,21 @@ else instance gDualVariantCons ∷ , Row.Lacks l dt , Row.Cons l (Dual p s i a) dt d , GDualVariant p s i dlt dt vt - ) ⇒ GDualVariant p s i (Cons l (Dual p s i a) dlt) d v where + ) ⇒ + GDualVariant p s i (Cons l (Dual p s i a) dlt) d v where gDualV _ pre duals = d where - _l = Proxy ∷ Proxy l + _l = Proxy ∷ Proxy l - duals' ∷ { | dt } - duals' = Record.delete _l duals - Dual (DualD prs ser) = gDualV (Proxy ∷ Proxy dlt) pre duals' - Dual (DualD fieldPrs fieldSer) = pre _l (Record.get _l duals) + duals' ∷ { | dt } + duals' = Record.delete _l duals + Dual (DualD prs ser) = gDualV (Proxy ∷ Proxy dlt) pre duals' + Dual (DualD fieldPrs fieldSer) = pre _l (Record.get _l duals) - prs' = (inj _l <$> fieldPrs) <|> (Variant.expand <$> prs) - ser' = ser # on _l fieldSer + prs' = (inj _l <$> fieldPrs) <|> (Variant.expand <$> prs) + ser' = ser # on _l fieldSer - d = dual prs' ser' + d = dual prs' ser' variant ∷ ∀ d dl p i v s diff --git a/src/Polyform/Dual/Record.purs b/src/Polyform/Dual/Record.purs index c98cb6a..8188ebc 100644 --- a/src/Polyform/Dual/Record.purs +++ b/src/Polyform/Dual/Record.purs @@ -23,21 +23,23 @@ instance categoryProductBuilder ∷ (Monoid i, Applicative s, Applicative (p i)) (pure identity) (const $ pure mempty) -insert ∷ ∀ i n o p prs prs' s ser ser' +insert + ∷ ∀ i n o p prs prs' s ser ser' . Row.Cons' n o ser ser' ⇒ Row.Cons' n o prs prs' ⇒ Functor (p i) ⇒ Proxy n → Dual p s i o - → Builder p s i { | ser'} ({ | prs}) ({ | prs'}) + → Builder p s i { | ser' } ({ | prs }) ({ | prs' }) insert l (Dual (DualD prs ser)) = Builder $ DualD (Record.Builder.insert l <$> prs) (ser <<< Record.get l) -build ∷ ∀ i o p s +build + ∷ ∀ i o p s . Functor (p i) - ⇒ Builder p s i { |o} {} { |o} - → Dual p s i { | o} + ⇒ Builder p s i { | o } {} { | o } + → Dual p s i { | o } build (Builder (DualD prs ser)) = dual (flip Record.Builder.build {} <$> prs) ser diff --git a/src/Polyform/Dual/Variant.purs b/src/Polyform/Dual/Variant.purs index 6e60119..9d4263a 100644 --- a/src/Polyform/Dual/Variant.purs +++ b/src/Polyform/Dual/Variant.purs @@ -15,7 +15,8 @@ import Unsafe.Coerce (unsafeCoerce) -- |`prefix` can be used to encode tagging of a given option. -- | Please take a look at `Polyform.Duals.Json.on` example -- | from `polyform-validators`. -on ∷ ∀ a i l p r r' s +on + ∷ ∀ a i l p r r' s . Row.Cons l a r r' ⇒ IsSymbol l ⇒ Alt (p i) @@ -34,14 +35,13 @@ on prefix label d (Dual (DualD restPrs restSer)) = expandCase = unsafeCoerce in dual - (inj label <$> prs <|> ((expandCase <$> restPrs ))) + (inj label <$> prs <|> ((expandCase <$> restPrs))) (restSer # Variant.on label ser) case_ ∷ ∀ i p s. Applicative (p i) ⇒ Dual p s i (Variant ()) case_ = dual prs ser where - prs = unsafeCoerce (\_ → unsafeCrashWith ("Dual.Variant.case_: trying to parse empty Variant")) - ser i = unsafeCrashWith ("Dual.Variant.case_: serializing empty Variant: " <> unsafeStringify i) - + prs = unsafeCoerce (\_ → unsafeCrashWith ("Dual.Variant.case_: trying to parse empty Variant")) + ser i = unsafeCrashWith ("Dual.Variant.case_: serializing empty Variant: " <> unsafeStringify i) foreign import unsafeStringify :: forall a. a -> String diff --git a/src/Polyform/Exceptor.purs b/src/Polyform/Exceptor.purs index fd22177..8a35a87 100644 --- a/src/Polyform/Exceptor.purs +++ b/src/Polyform/Exceptor.purs @@ -18,8 +18,7 @@ import Data.Profunctor.Strong (class Strong) -- | * No `Semigroup e` constraint in its `Alt` instance (consistent with `Either`) -- | -- | * Provides `Parallel` instance. -newtype Exceptor m e i o - = Exceptor (Star (ExceptT e m) i o) +newtype Exceptor m e i o = Exceptor (Star (ExceptT e m) i o) derive instance newtypeExceptor ∷ Newtype (Exceptor m r i o) _ derive newtype instance functorExceptor ∷ Applicative m ⇒ Functor (Exceptor m e i) @@ -43,11 +42,10 @@ instance altExceptor ∷ (Monad m) ⇒ Alt (Exceptor m e i) where ExceptT do runExceptT (v1 i) >>= case _ of - (Right o1) → pure $ pure o1 - (Left _) → runExceptT (v2 i) + (Right o1) → pure $ pure o1 + (Left _) → runExceptT (v2 i) -newtype ParExceptor f e i o - = ParExceptor (Star (Compose f (Either e)) i o) +newtype ParExceptor f e i o = ParExceptor (Star (Compose f (Either e)) i o) derive newtype instance functorParExceptor ∷ Applicative f ⇒ Functor (ParExceptor f e i) derive newtype instance applyParExceptor ∷ Applicative f ⇒ Apply (ParExceptor f e i) diff --git a/src/Polyform/Reporter.purs b/src/Polyform/Reporter.purs index 5839b88..d0dc1d2 100644 --- a/src/Polyform/Reporter.purs +++ b/src/Polyform/Reporter.purs @@ -36,8 +36,7 @@ import Data.Tuple (Tuple(..)) import Data.Validation.Semigroup (V(..), validation) import Polyform.Validator (Validator(..), runValidator) -newtype Reporter m r i o - = Reporter (Star (MaybeT (WriterT r m)) i o) +newtype Reporter m r i o = Reporter (Star (MaybeT (WriterT r m)) i o) derive instance newtypeReporter ∷ Newtype (Reporter m r i b) _ derive newtype instance functorReporter ∷ (Functor m) ⇒ Functor (Reporter m e i) @@ -63,8 +62,7 @@ derive newtype instance altReporter ∷ (Monad m, Monoid r) ⇒ Alt (Reporter m derive newtype instance plusReporter ∷ (Monad m, Monoid r) ⇒ Plus (Reporter m r i) -- where empty = Reporter empty -type R r a - = Tuple (Maybe a) r +type R r a = Tuple (Maybe a) r liftV ∷ ∀ a r. Monoid r ⇒ V r a → R r a liftV (V (Right a)) = Tuple (Just a) mempty @@ -121,8 +119,8 @@ liftValidatorWithM f g validator = Reporter $ Star run run i = MaybeT $ WriterT $ runValidator validator i >>= case _ of - V (Left e) → f (Tuple i e) >>= Tuple Nothing >>> pure - V (Right o) → g (Tuple i o) >>= Tuple (Just o) >>> pure + V (Left e) → f (Tuple i e) >>= Tuple Nothing >>> pure + V (Right o) → g (Tuple i o) >>= Tuple (Just o) >>> pure toValidator ∷ ∀ e i m. Functor m ⇒ Monoid e ⇒ Reporter m e i ~> Validator m e i toValidator (Reporter (Star f)) = Validator (Star (f >>> un MaybeT >>> un WriterT >>> map toV >>> Compose)) @@ -145,8 +143,7 @@ liftFnEither f = liftFnR $ f >>> liftEitherR -- | Provides access to validation result so you can -- | `bimap` over `r` and `b` type in resulting `R r b`. -newtype BifunctorReporter m i r o - = BifunctorReporter (Reporter m r i o) +newtype BifunctorReporter m i r o = BifunctorReporter (Reporter m r i o) derive instance newtypeBifunctorReporter ∷ Newtype (BifunctorReporter m i r o) _ @@ -159,13 +156,13 @@ instance bifunctorBifunctorReporter ∷ Monad m ⇒ Bifunctor (BifunctorReporter v ← runReporter rep i pure $ bimap (map r) l v -bimapReporter ∷ - ∀ i m o o' r r'. - (Monad m) ⇒ - (r → r') → - (o → o') → - Reporter m r i o → - Reporter m r' i o' +bimapReporter + ∷ ∀ i m o o' r r' + . (Monad m) + ⇒ (r → r') + → (o → o') + → Reporter m r i o + → Reporter m r' i o' bimapReporter l r = unwrap <<< bimap l r <<< BifunctorReporter lmapReporter ∷ ∀ i m o r r'. Monad m ⇒ (r → r') → Reporter m r i o → Reporter m r' i o @@ -175,5 +172,5 @@ lmapM ∷ ∀ i m r r'. Monad m ⇒ (r → m r') → Reporter m r i ~> Reporter lmapM f reporter = liftFnMR $ runReporter reporter >=> case _ of - Tuple (Just a) r → Tuple (Just a) <$> f r - Tuple _ r → Tuple Nothing <$> f r + Tuple (Just a) r → Tuple (Just a) <$> f r + Tuple _ r → Tuple Nothing <$> f r diff --git a/src/Polyform/Reporter/Dual.purs b/src/Polyform/Reporter/Dual.purs index 4f3b5a2..358ae9a 100644 --- a/src/Polyform/Reporter/Dual.purs +++ b/src/Polyform/Reporter/Dual.purs @@ -9,8 +9,7 @@ module Polyform.Reporter.Dual , newtypeIso , runReporter , runSerializer - ) - where + ) where import Prelude @@ -40,9 +39,10 @@ runSerializer = map runWriter <<< Dual.serializer hoist ∷ ∀ e i o m m'. Functor m ⇒ (m ~> m') → Dual m e i o → Dual m' e i o hoist nt (Dual.Dual (Dual.DualD reporter ser)) = Dual.dual reporter' ser where - reporter' = Reporter.hoist nt reporter + reporter' = Reporter.hoist nt reporter -liftValidatorDual ∷ ∀ i m r +liftValidatorDual + ∷ ∀ i m r . Monad m ⇒ Monoid r ⇒ Validator.Dual.Dual m r i ~> Dual m r i @@ -50,7 +50,8 @@ liftValidatorDual d = Dual.dual (Reporter.liftValidator $ Dual.parser d) (map lift (Dual.serializer d)) -liftValidatorDualWith ∷ ∀ e i m o r +liftValidatorDualWith + ∷ ∀ e i m o r . Monad m ⇒ Monoid r ⇒ (Tuple i e → r) @@ -61,26 +62,25 @@ liftValidatorDualWith fe fo d = Dual.dual (Reporter.liftValidatorWith fe fo $ Dual.parser d) ser where - ser ∷ o → Writer r i - ser = attachOutput (Dual.serializer d) >>> lift >=> \t@(Tuple i _) → do - let - r = fo t - tell r - pure i + ser ∷ o → Writer r i + ser = attachOutput (Dual.serializer d) >>> lift >=> \t@(Tuple i _) → do + let + r = fo t + tell r + pure i - attachOutput :: ∀ m'. Applicative m' ⇒ (o -> m' i) -> o -> m' (i /\ o) - attachOutput - = un Star - <<< Profunctor.lcmap (\o → Tuple o o) - <<< Profunctor.Strong.first - <<< Star + attachOutput :: ∀ m'. Applicative m' ⇒ (o -> m' i) -> o -> m' (i /\ o) + attachOutput = un Star + <<< Profunctor.lcmap (\o → Tuple o o) + <<< Profunctor.Strong.first + <<< Star mapReport ∷ ∀ i m o r r'. Monad m ⇒ (r → r') → Dual m r i o → Dual m r' i o mapReport f (Dual.Dual (Dual.DualD reporter ser)) = Dual.dual reporter' ser' where - reporter' = Reporter.lmapM (f >>> pure) reporter + reporter' = Reporter.lmapM (f >>> pure) reporter - ser' = mapWriter (map f) <$> ser + ser' = mapWriter (map f) <$> ser iso ∷ ∀ e i m o. Monoid e ⇒ Monad m ⇒ (i → o) → (o → i) → Dual m e i o iso p s = liftValidatorDual (Validator.Dual.iso p s) diff --git a/src/Polyform/Tokenized.purs b/src/Polyform/Tokenized.purs index ffe8a3c..f8b0113 100644 --- a/src/Polyform/Tokenized.purs +++ b/src/Polyform/Tokenized.purs @@ -15,8 +15,7 @@ import Data.Tuple.Nested ((/\), type (/\)) -- | TODO: -- | Should we move from `List i` to `Array i /\ Int` -- | so we can improve error reporting? -newtype Tokenized p i o - = Tokenized (p (List i /\ Maybe i) (List i /\ o)) +newtype Tokenized p i o = Tokenized (p (List i /\ Maybe i) (List i /\ o)) instance functorTokenized ∷ (Profunctor p) ⇒ Functor (Tokenized p i) where map f (Tokenized p) = Tokenized (rmap (map f) p) @@ -24,7 +23,8 @@ instance functorTokenized ∷ (Profunctor p) ⇒ Functor (Tokenized p i) where instance applyTokenized ∷ (Profunctor p, Semigroupoid p, Strong p) ⇒ Apply (Tokenized p i) where apply (Tokenized pf) (Tokenized pa) = Tokenized - $ let + $ + let carry (l /\ a2b) = case l of h : t → ((t /\ (Just h)) /\ a2b) Nil → ((Nil /\ Nothing) /\ a2b) @@ -36,7 +36,8 @@ instance applyTokenized ∷ (Profunctor p, Semigroupoid p, Strong p) ⇒ Apply ( instance applicativeTokenized ∷ (Category p, Profunctor p, Strong p) ⇒ Applicative (Tokenized p i) where pure i = Tokenized - $ let + $ + let set (l /\ h) = case h of Just h' → ((h' : l) /\ i) Nothing → (l /\ i) diff --git a/src/Polyform/Tokenized/Dual.purs b/src/Polyform/Tokenized/Dual.purs index 4d18bd8..1696f50 100644 --- a/src/Polyform/Tokenized/Dual.purs +++ b/src/Polyform/Tokenized/Dual.purs @@ -12,8 +12,7 @@ import Polyform.Dual (Dual, dual, parser, serializer) as Polyform.Dual import Polyform.Tokenized (Tokenized) import Polyform.Tokenized (liftUntokenized, unliftUntokenized) as Tokenized -data DualD p s i o o' - = DualD (Tokenized p i o') (o → s (List i)) +data DualD p s i o o' = DualD (Tokenized p i o') (o → s (List i)) derive instance functorDualD ∷ (Profunctor p) ⇒ Functor (DualD p s i o) @@ -27,6 +26,7 @@ instance profunctorDualD ∷ (Profunctor p) ⇒ Profunctor (DualD p s i) where dimap l r (DualD prs ser) = DualD (map r prs) (l >>> ser) newtype Dual p s i o = Dual (DualD p s i o o) + derive instance newtypeDual ∷ Newtype (Dual p s i o) _ dual ∷ ∀ i o p s. Tokenized p i o → (o → s (List i)) → Dual p s i o @@ -35,13 +35,13 @@ dual p s = Dual (DualD p s) pureDual ∷ ∀ i o p s. Category p ⇒ Strong p ⇒ Applicative s ⇒ o → Dual p s i o pureDual o = Dual (pure o) -diverge ∷ - ∀ i o o' p s. - Functor (p i) ⇒ - Profunctor p ⇒ - (o' → o) → - Dual p s i o → - DualD p s i o' o +diverge + ∷ ∀ i o o' p s + . Functor (p i) + ⇒ Profunctor p + ⇒ (o' → o) + → Dual p s i o + → DualD p s i o' o diverge f = lcmap f <<< unwrap infixl 5 diverge as ~ diff --git a/src/Polyform/Tokenized/Validator.purs b/src/Polyform/Tokenized/Validator.purs index 26a59e0..b09e177 100644 --- a/src/Polyform/Tokenized/Validator.purs +++ b/src/Polyform/Tokenized/Validator.purs @@ -9,8 +9,7 @@ import Polyform.Tokenized (Tokenized, liftUntokenized) as Tokenized import Polyform.Tokenized (unliftUntokenized) import Polyform.Validator (Validator, liftFnEither, runValidator) as Validator -type Validator m err - = Tokenized.Tokenized (Validator.Validator m err) +type Validator m err = Tokenized.Tokenized (Validator.Validator m err) liftUntokenized ∷ ∀ err i o m. Monad m ⇒ Semigroup err ⇒ err → Validator.Validator m err i o → Validator m err i o liftUntokenized e v = Tokenized.liftUntokenized (v <<< l) diff --git a/src/Polyform/Validator.purs b/src/Polyform/Validator.purs index 80ef6be..32f7193 100644 --- a/src/Polyform/Validator.purs +++ b/src/Polyform/Validator.purs @@ -41,6 +41,7 @@ import Data.Tuple (Tuple(..)) import Data.Validation.Semigroup (V(..), invalid, validation) newtype Validator m e i o = Validator (Star (Compose m (V e)) i o) + derive instance newtypeValidator ∷ Newtype (Validator m r i o) _ derive newtype instance functorValidator ∷ (Applicative m) ⇒ Functor (Validator m e i) derive newtype instance applyValidator ∷ (Applicative m, Semigroup e) ⇒ Apply (Validator m e i) @@ -125,13 +126,13 @@ invalidate ∷ ∀ e i o m. Applicative m ⇒ (i → e) → Validator m e i o invalidate inv = liftFnMaybe inv (const Nothing) check ∷ ∀ e i m. Applicative m ⇒ Semigroup e ⇒ (i → e) → (i → Boolean) → Validator m e i i -check e c = liftFnV \i → if c i - then pure i +check e c = liftFnV \i → + if c i then pure i else invalid (e i) checkM ∷ ∀ e i m. Monad m ⇒ Semigroup e ⇒ (i → e) → (i → m Boolean) → Validator m e i i -checkM e c = liftFnMV \i → c i >>= if _ - then pure $ pure i +checkM e c = liftFnMV \i → c i >>= + if _ then pure $ pure i else pure $ invalid (e i) -- | Lifts natural transformation so it hoists internal validator functor. @@ -141,6 +142,7 @@ hoist n (Validator (Star v)) = Validator $ Star (map (bihoistCompose n identity) -- | Provides access to validation result -- | so you can `bimap` over `e` and `b` type in resulting `V e b`. newtype BifunctorValidator m i e o = BifunctorValidator (Validator m e i o) + derive instance newtypeBifunctorValidator ∷ Newtype (BifunctorValidator m i e o) _ instance bifunctorBifunctorValidator ∷ Monad m ⇒ Bifunctor (BifunctorValidator m i) where @@ -149,7 +151,8 @@ instance bifunctorBifunctorValidator ∷ Monad m ⇒ Bifunctor (BifunctorValidat Compose v = f i map (bimap l r) v -bimapValidator ∷ ∀ i e e' m o o' +bimapValidator + ∷ ∀ i e e' m o o' . (Monad m) ⇒ (e → e') → (o → o') @@ -171,16 +174,18 @@ lmapMWithInput f v = liftFnMV $ \i → runValidator v i >>= case _ of V (Right a) → pure $ V (Right a) bimapM - ∷ ∀ e e' i m o o'. Monad m + ∷ ∀ e e' i m o o' + . Monad m ⇒ Semigroup e' ⇒ (e → m e') → (o → m o') → Validator m e i o → Validator m e' i o' -bimapM l r v = liftFnM r <<< lmapM l v +bimapM l r v = liftFnM r <<< lmapM l v bimapMWithInput - ∷ ∀ e e' i m o o'. Monad m + ∷ ∀ e e' i m o o' + . Monad m ⇒ Semigroup e' ⇒ ((Tuple i e) → m e') → ((Tuple i o) → m o') diff --git a/src/Polyform/Validator/Dual.purs b/src/Polyform/Validator/Dual.purs index de44a16..0e3cc65 100644 --- a/src/Polyform/Validator/Dual.purs +++ b/src/Polyform/Validator/Dual.purs @@ -27,11 +27,9 @@ import Polyform.Dual (dual) as Polyform.Dual import Polyform.Validator (Validator, lmapValidator) import Polyform.Validator as Validator -type Dual m e - = Dual.Dual (Validator m e) Identity +type Dual m e = Dual.Dual (Validator m e) Identity -type DualD m e - = Dual.DualD (Validator m e) Identity +type DualD m e = Dual.DualD (Validator m e) Identity runValidator ∷ ∀ e i o m. Monad m ⇒ Dual.Dual (Validator m e) m i o → (i → m (V e o)) runValidator = Validator.runValidator <<< Dual.parser diff --git a/src/Polyform/Validator/Dual/Generic.purs b/src/Polyform/Validator/Dual/Generic.purs index 99b8845..73c0e8e 100644 --- a/src/Polyform/Validator/Dual/Generic.purs +++ b/src/Polyform/Validator/Dual/Generic.purs @@ -12,8 +12,9 @@ import Polyform.Validator (Validator) import Prim.RowList (class RowToList) import Type.Proxy (Proxy) -sum ∷ ∀ a m e i rep r s - . Monad m +sum + ∷ ∀ a m e i rep r s + . Monad m ⇒ Semigroup e ⇒ Generic a rep ⇒ GDualSum (Validator m e) s i rep r @@ -22,7 +23,8 @@ sum ∷ ∀ a m e i rep r s → Dual (Validator m e) s i a sum = Dual.Generic.sum -variant ∷ ∀ e i d dl m s v +variant + ∷ ∀ e i d dl m s v . Monad m ⇒ RowToList d dl ⇒ Semigroup e diff --git a/src/Polyform/Validator/Dual/Pure.purs b/src/Polyform/Validator/Dual/Pure.purs index 3b16c9d..826d857 100644 --- a/src/Polyform/Validator/Dual/Pure.purs +++ b/src/Polyform/Validator/Dual/Pure.purs @@ -13,8 +13,8 @@ type Dual e i o = Validator.Dual.Dual Identity e i o generalize ∷ ∀ e i m o. Applicative m ⇒ Dual e i o → Validator.Dual.Dual m e i o generalize = Dual.hoist g where - g ∷ ∀ a. Identity a → m a - g (Identity a) = pure a + g ∷ ∀ a. Identity a → m a + g (Identity a) = pure a runValidator ∷ ∀ e i o. Dual e i o → i → V e o runValidator dual = un Identity <<< Dual.runValidator dual diff --git a/src/Polyform/Validator/Par.purs b/src/Polyform/Validator/Par.purs index b2935e1..b2256b5 100644 --- a/src/Polyform/Validator/Par.purs +++ b/src/Polyform/Validator/Par.purs @@ -13,6 +13,7 @@ import Data.Validation.Semigroup (validation) import Polyform.Validator (Validator(..)) newtype Par m e i o = Par (Validator m e i o) + derive instance newtypeVaildation ∷ Newtype (Par m e i o) _ derive instance functorPar ∷ (Applicative m, Semigroup e) ⇒ Functor (Par m e i) @@ -30,10 +31,10 @@ instance altPar ∷ (Monad m, Parallel f m, Monoid e) ⇒ Alt (Par m e i) where alt (Par (Validator (Star mv1))) (Par (Validator (Star mv2))) = Par $ Validator $ Star $ f where - f i = Compose $ Parallel.sequential ado - r1 ← Parallel.parallel (unwrap $ mv1 i) - r2 ← Parallel.parallel (unwrap $ mv2 i) - in (validation (const r2) pure r1) + f i = Compose $ Parallel.sequential ado + r1 ← Parallel.parallel (unwrap $ mv1 i) + r2 ← Parallel.parallel (unwrap $ mv2 i) + in (validation (const r2) pure r1) instance plusPar ∷ (Monad m, Monoid e, Parallel f m) ⇒ Plus (Par m e i) where empty = Par empty diff --git a/src/Polyform/Validator/Record.purs b/src/Polyform/Validator/Record.purs index f22e0a4..b31ebb7 100644 --- a/src/Polyform/Validator/Record.purs +++ b/src/Polyform/Validator/Record.purs @@ -25,8 +25,9 @@ instance , IsSymbol l , Apply m , TypeEquals (m a) (m' a) - ) => FoldingWithIndex Sequence (Proxy l) (m { | r }) (m' a) (m { | r'}) where - foldingWithIndex _ l mr ma = Record.insert l <$> (Type.Equality.from ma) <*> mr + ) => + FoldingWithIndex Sequence (Proxy l) (m { | r }) (m' a) (m { | r' }) where + foldingWithIndex _ l mr ma = Record.insert l <$> (Type.Equality.from ma) <*> mr sequence :: forall m r r'. Applicative m => HFoldlWithIndex Sequence (m {}) r (m r') => r -> m r' sequence r = hfoldlWithIndex Sequence (pure {} :: m {}) r @@ -34,8 +35,11 @@ sequence r = hfoldlWithIndex Sequence (pure {} :: m {}) r data MapLookup err = MapLookup (String -> err) instance - (IsSymbol l, Monad m, Semigroup err) - => MappingWithIndex (MapLookup err) (Proxy l) (Validator m err i o) (Validator m (Map String err) (Map String i) o) where + ( IsSymbol l + , Monad m + , Semigroup err + ) => + MappingWithIndex (MapLookup err) (Proxy l) (Validator m err i o) (Validator m (Map String err) (Map String i) o) where mappingWithIndex (MapLookup err) l v = do let k = reflectSymbol l @@ -45,7 +49,6 @@ instance mapLookup :: forall t184 t185 t187 t188. MappingWithIndex (MapLookup t188) t187 t184 t185 => (String -> t188) -> t187 -> t184 -> t185 mapLookup mkErr = mappingWithIndex (MapLookup mkErr) - -- You can also build records one step at a time newtype Builder m e i o o' = Builder (Validator m e i (Record.Builder o o')) @@ -56,19 +59,21 @@ instance semigroupoidBuilder ∷ (Semigroup i, Semigroup e, Monad m) ⇒ Semigro instance categoryBuilder ∷ (Monoid i, Semigroup e, Monad m) ⇒ Category (Builder m e i) where identity = Builder $ pure identity -insert ∷ ∀ a e i o o' n m +insert + ∷ ∀ a e i o o' n m . Row.Cons' n a o o' ⇒ Semigroup e ⇒ Applicative m ⇒ Proxy n → Validator m e i a - → Builder m e i ({ | o}) ({ | o'}) + → Builder m e i ({ | o }) ({ | o' }) insert l v = Builder $ (Record.Builder.insert l <$> v) -build ∷ ∀ e i m o +build + ∷ ∀ e i m o . Applicative m ⇒ Semigroup e - ⇒ Builder m e i {} { |o} - → Validator m e i { | o} + ⇒ Builder m e i {} { | o } + → Validator m e i { | o } build (Builder v) = (flip Record.Builder.build {} <$> v)