Compare commits
10 commits
fa290264e9
...
413f767e4f
Author | SHA1 | Date | |
---|---|---|---|
![]() |
413f767e4f | ||
![]() |
9af22d1533 | ||
![]() |
ac57a1162c | ||
![]() |
8078efd158 | ||
![]() |
ebce1ab12a | ||
![]() |
55168d8e64 | ||
![]() |
958766021b | ||
![]() |
e514f9cef2 | ||
![]() |
425549bc7b | ||
![]() |
ec3afab337 |
15 changed files with 878 additions and 123 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use_nix
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@
|
|||
/.psc*
|
||||
/.purs*
|
||||
/.psa*
|
||||
/.spago/
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2015, Athan Clark
|
||||
Copyright (c) 2015, 2016, 2017, 2018, 2019, 2020 Athan Clark
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
25
README.md
25
README.md
|
@ -1,7 +1,30 @@
|
|||
# purescript-tuples-native
|
||||
|
||||
This library defines tuple data types that are represented under-the-hood as heterogeneous arrays to JavaScript - useful for
|
||||
foreign interfaces:
|
||||
foreign interfaces. A set of `xt` functions are exposed to translate these native Tuples into Purescript pairs
|
||||
or Nested tuples. So for example:
|
||||
|
||||
```purescript
|
||||
-- Main.purs
|
||||
import Data.Tuple.Native (T2, xt)
|
||||
import Data.Tuple (Tuple)
|
||||
|
||||
foreign import lenTupleImpl :: String -> T2 String Int
|
||||
|
||||
lenTuple :: String -> Tuple String Int
|
||||
lenTuple s = xt $ lenTupleImpl s
|
||||
```
|
||||
|
||||
Could let you wrap this Javascript function
|
||||
```javascript
|
||||
"use strict";
|
||||
function lenTuple (string) {
|
||||
return [string, string.length]
|
||||
}
|
||||
exports.lenTupleImpl = lenTuple
|
||||
```
|
||||
|
||||
You can also extract indidual elements directly from the Native tuple using `prj`.
|
||||
|
||||
```purescript
|
||||
import Data.Tuple.Native (T3, t3, prj)
|
||||
|
|
|
@ -8,14 +8,13 @@
|
|||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"repository": {
|
||||
"url": "git://github.com/athanclark/purescript-tuples-native.git",
|
||||
"url": "https://github.com/athanclark/purescript-tuples-native.git",
|
||||
"type": "git"
|
||||
},
|
||||
"dependencies": {
|
||||
"purescript-prelude": "^4.1.1",
|
||||
"purescript-unsafe-coerce": "^4.0.0",
|
||||
"purescript-typelevel": "git://github.com/athanclark/purescript-typelevel.git#609e8b28e9aa912988085906e0ac5ea5b9b49ca0",
|
||||
"purescript-generics-rep": "^6.1.1"
|
||||
"purescript-typelevel": "^6.0.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
"purescript-psci-support": "^4.0.0"
|
||||
|
|
13
nix/easy-ps.nix
Normal file
13
nix/easy-ps.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ pkgs ? import ./pinned.nix { } }:
|
||||
|
||||
import
|
||||
(
|
||||
pkgs.fetchFromGitHub {
|
||||
owner = "justinwoo";
|
||||
repo = "easy-purescript-nix";
|
||||
rev = "master";
|
||||
sha256 = "03g9xq451dmrkq8kiz989wnl8k0lmj60ajflz44bhp7cm08hf3bw";
|
||||
}
|
||||
) {
|
||||
inherit pkgs;
|
||||
}
|
6
nix/pinned.nix
Normal file
6
nix/pinned.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
import (
|
||||
builtins.fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/21.11.tar.gz";
|
||||
sha256 = "162dywda2dvfj1248afxc45kcrg83appjd0nmdb541hl7rnncf02";
|
||||
}
|
||||
)
|
5
package.json
Normal file
5
package.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"spago": "^0.20.9"
|
||||
}
|
||||
}
|
19
shell.nix
Normal file
19
shell.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ pkgs ? import ./nix/pinned.nix { } }:
|
||||
let
|
||||
easy-ps = import ./nix/easy-ps.nix { inherit pkgs; };
|
||||
|
||||
build = pkgs.writeShellScriptBin "build" ''
|
||||
#!/usr/bin/env bash
|
||||
purs compile "src/**/*.purs" "test/**/*.purs"
|
||||
'';
|
||||
in
|
||||
pkgs.mkShell {
|
||||
name = "purescript-reactix-d3";
|
||||
|
||||
buildInputs = [
|
||||
easy-ps.purs-0_15_4
|
||||
easy-ps.psc-package
|
||||
build
|
||||
pkgs.dhall-json
|
||||
];
|
||||
}
|
675
spago.lock
Normal file
675
spago.lock
Normal file
|
@ -0,0 +1,675 @@
|
|||
{
|
||||
"workspace": {
|
||||
"packages": {
|
||||
"tuples-native": {
|
||||
"path": "./",
|
||||
"core": {
|
||||
"dependencies": [
|
||||
"console",
|
||||
"effect",
|
||||
"functions",
|
||||
"prelude",
|
||||
"tuples",
|
||||
"typelevel",
|
||||
"typelevel-prelude"
|
||||
],
|
||||
"build_plan": [
|
||||
"console",
|
||||
"control",
|
||||
"effect",
|
||||
"functions",
|
||||
"invariant",
|
||||
"newtype",
|
||||
"partial",
|
||||
"prelude",
|
||||
"safe-coerce",
|
||||
"tuples",
|
||||
"type-equality",
|
||||
"typelevel",
|
||||
"typelevel-prelude",
|
||||
"unsafe-coerce"
|
||||
]
|
||||
},
|
||||
"test": {
|
||||
"dependencies": [],
|
||||
"build_plan": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"package_set": {
|
||||
"address": {
|
||||
"registry": "61.2.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.2",
|
||||
"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.1.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.1.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",
|
||||
"jsdom": "1.0.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.20",
|
||||
"precise": "6.0.0",
|
||||
"precise-datetime": "7.0.0",
|
||||
"prelude": "6.0.1",
|
||||
"prettier-printer": "3.0.0",
|
||||
"printf": "0.1.0",
|
||||
"priority-queue": "0.1.2",
|
||||
"profunctor": "6.0.1",
|
||||
"profunctor-lenses": "8.0.0",
|
||||
"protobuf": "4.4.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": "7.0.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.1",
|
||||
"spec-discovery": "8.4.0",
|
||||
"spec-mocha": "5.1.1",
|
||||
"spec-node": "0.0.3",
|
||||
"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-subtlecrypto": "0.1.0",
|
||||
"yoga-tree": "1.0.0",
|
||||
"z3": "0.0.2",
|
||||
"zipperarray": "2.0.0"
|
||||
}
|
||||
},
|
||||
"extra_packages": {}
|
||||
},
|
||||
"packages": {
|
||||
"console": {
|
||||
"type": "registry",
|
||||
"version": "6.1.0",
|
||||
"integrity": "sha256-CxmAzjgyuGDmt9FZW51VhV6rBPwR6o0YeKUzA9rSzcM=",
|
||||
"dependencies": [
|
||||
"effect",
|
||||
"prelude"
|
||||
]
|
||||
},
|
||||
"control": {
|
||||
"type": "registry",
|
||||
"version": "6.0.0",
|
||||
"integrity": "sha256-sH7Pg9E96JCPF9PIA6oQ8+BjTyO/BH1ZuE/bOcyj4Jk=",
|
||||
"dependencies": [
|
||||
"newtype",
|
||||
"prelude"
|
||||
]
|
||||
},
|
||||
"effect": {
|
||||
"type": "registry",
|
||||
"version": "4.0.0",
|
||||
"integrity": "sha256-eBtZu+HZcMa5HilvI6kaDyVX3ji8p0W9MGKy2K4T6+M=",
|
||||
"dependencies": [
|
||||
"prelude"
|
||||
]
|
||||
},
|
||||
"functions": {
|
||||
"type": "registry",
|
||||
"version": "6.0.0",
|
||||
"integrity": "sha256-adMyJNEnhGde2unHHAP79gPtlNjNqzgLB8arEOn9hLI=",
|
||||
"dependencies": [
|
||||
"prelude"
|
||||
]
|
||||
},
|
||||
"invariant": {
|
||||
"type": "registry",
|
||||
"version": "6.0.0",
|
||||
"integrity": "sha256-RGWWyYrz0Hs1KjPDA+87Kia67ZFBhfJ5lMGOMCEFoLo=",
|
||||
"dependencies": [
|
||||
"control",
|
||||
"prelude"
|
||||
]
|
||||
},
|
||||
"newtype": {
|
||||
"type": "registry",
|
||||
"version": "5.0.0",
|
||||
"integrity": "sha256-gdrQu8oGe9eZE6L3wOI8ql/igOg+zEGB5ITh2g+uttw=",
|
||||
"dependencies": [
|
||||
"prelude",
|
||||
"safe-coerce"
|
||||
]
|
||||
},
|
||||
"partial": {
|
||||
"type": "registry",
|
||||
"version": "4.0.0",
|
||||
"integrity": "sha256-fwXerld6Xw1VkReh8yeQsdtLVrjfGiVuC5bA1Wyo/J4=",
|
||||
"dependencies": []
|
||||
},
|
||||
"prelude": {
|
||||
"type": "registry",
|
||||
"version": "6.0.1",
|
||||
"integrity": "sha256-o8p6SLYmVPqzXZhQFd2hGAWEwBoXl1swxLG/scpJ0V0=",
|
||||
"dependencies": []
|
||||
},
|
||||
"safe-coerce": {
|
||||
"type": "registry",
|
||||
"version": "2.0.0",
|
||||
"integrity": "sha256-a1ibQkiUcbODbLE/WAq7Ttbbh9ex+x33VCQ7GngKudU=",
|
||||
"dependencies": [
|
||||
"unsafe-coerce"
|
||||
]
|
||||
},
|
||||
"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": {
|
||||
"type": "registry",
|
||||
"version": "6.0.0",
|
||||
"integrity": "sha256-Iu7INcwTC/SbKcienMe7KKQvWku2VhCZSGCvrQWVVoc=",
|
||||
"dependencies": [
|
||||
"partial",
|
||||
"prelude",
|
||||
"tuples",
|
||||
"typelevel-prelude",
|
||||
"unsafe-coerce"
|
||||
]
|
||||
},
|
||||
"typelevel-prelude": {
|
||||
"type": "registry",
|
||||
"version": "7.0.0",
|
||||
"integrity": "sha256-uFF2ph+vHcQpfPuPf2a3ukJDFmLhApmkpTMviHIWgJM=",
|
||||
"dependencies": [
|
||||
"prelude",
|
||||
"type-equality"
|
||||
]
|
||||
},
|
||||
"unsafe-coerce": {
|
||||
"type": "registry",
|
||||
"version": "6.0.0",
|
||||
"integrity": "sha256-IqIYW4Vkevn8sI+6aUwRGvd87tVL36BBeOr0cGAE7t0=",
|
||||
"dependencies": []
|
||||
}
|
||||
}
|
||||
}
|
15
spago.yaml
Normal file
15
spago.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
package:
|
||||
name: tuples-native
|
||||
dependencies:
|
||||
- console
|
||||
- effect
|
||||
- functions
|
||||
- prelude
|
||||
- tuples
|
||||
- typelevel
|
||||
- typelevel-prelude
|
||||
workspace:
|
||||
packageSet:
|
||||
registry: 61.2.0
|
||||
extraPackages: {}
|
||||
|
|
@ -1,111 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
exports.prjImpl = function projImpl1 (n) {
|
||||
return function projImpl2 (t) {
|
||||
return t[n];
|
||||
};
|
||||
export function prjImpl(n, t) {
|
||||
return t[n];
|
||||
};
|
||||
|
||||
exports.t2 = function t21 (a) {
|
||||
return function t22 (b) {
|
||||
return [a,b];
|
||||
};
|
||||
export function t2_ (a, b) {
|
||||
return [a,b];
|
||||
};
|
||||
|
||||
exports.t3 = function t31 (a) {
|
||||
return function t32 (b) {
|
||||
return function t33 (c) {
|
||||
return [a,b,c];
|
||||
};
|
||||
};
|
||||
export function t3_ (a,b,c) {
|
||||
return [a,b,c];
|
||||
};
|
||||
|
||||
exports.t4 = function t41 (a) {
|
||||
return function t42 (b) {
|
||||
return function t43 (c) {
|
||||
return function t44 (d) {
|
||||
return [a,b,c,d];
|
||||
};
|
||||
};
|
||||
};
|
||||
export function t4_ (a,b,c,d) {
|
||||
return [a,b,c,d];
|
||||
};
|
||||
|
||||
exports.t5 = function t51 (a) {
|
||||
return function t52 (b) {
|
||||
return function t53 (c) {
|
||||
return function t54 (d) {
|
||||
return function t55 (e) {
|
||||
return [a,b,c,d,e];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
export function t5_ (a,b,c,d,e) {
|
||||
return [a,b,c,d,e];
|
||||
};
|
||||
|
||||
exports.t6 = function t61 (a) {
|
||||
return function t62 (b) {
|
||||
return function t63 (c) {
|
||||
return function t64 (d) {
|
||||
return function t65 (e) {
|
||||
return function t66 (f) {
|
||||
return [a,b,c,d,e,f];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
export function t6_ (a,b,c,d,e,f) {
|
||||
return [a,b,c,d,e,f];
|
||||
};
|
||||
|
||||
exports.t7 = function t71 (a) {
|
||||
return function t72 (b) {
|
||||
return function t73 (c) {
|
||||
return function t74 (d) {
|
||||
return function t75 (e) {
|
||||
return function t76 (f) {
|
||||
return function t77 (g) {
|
||||
return [a,b,c,d,e,f,g];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
export function t7_ (a,b,c,d,e,f,g) {
|
||||
return [a,b,c,d,e,f,g];
|
||||
};
|
||||
|
||||
exports.t8 = function t81 (a) {
|
||||
return function t82 (b) {
|
||||
return function t83 (c) {
|
||||
return function t84 (d) {
|
||||
return function t85 (e) {
|
||||
return function t86 (f) {
|
||||
return function t87 (g) {
|
||||
return function t88 (h) {
|
||||
return [a,b,c,d,e,f,g,h];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
export function t8_ (a,b,c,d,e,f,g,h) {
|
||||
return [a,b,c,d,e,f,g,h];
|
||||
};
|
||||
|
||||
exports.t9 = function t91 (a) {
|
||||
return function t92 (b) {
|
||||
return function t93 (c) {
|
||||
return function t94 (d) {
|
||||
return function t95 (e) {
|
||||
return function t96 (f) {
|
||||
return function t97 (g) {
|
||||
return function t98 (h) {
|
||||
return function t99 (i) {
|
||||
return [a,b,c,d,e,f,g,h,i];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
export function t9_ (a,b,c,d,e,f,g,h,i) {
|
||||
return [a,b,c,d,e,f,g,h,i];
|
||||
};
|
||||
|
|
|
@ -4,20 +4,53 @@ module Data.Tuple.Native
|
|||
( TupleN
|
||||
, T2, T3, T4, T5, T6, T7, T8, T9
|
||||
, t2, t3, t4, t5, t6, t7, t8, t9
|
||||
, t2_, t3_, t4_, t5_, t6_, t7_, t8_, t9_
|
||||
, xt
|
||||
, xt2, xt3, xt4, xt5, xt6, xt7, xt8, xt9
|
||||
, prj
|
||||
, class TupleSize, class ShowNat
|
||||
) where
|
||||
|
||||
import Data.Function.Uncurried (Fn2, Fn3, Fn4, Fn5, Fn6, Fn7, Fn8, Fn9, runFn2, runFn3, runFn4, runFn5, runFn6, runFn7, runFn8, runFn9)
|
||||
import Data.Generic.Rep (class Generic, Constructor(..), Argument(..), Product(..))
|
||||
import Data.Tuple as DT
|
||||
import Data.Tuple.Nested as DTN
|
||||
import Data.Typelevel.Num (D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, class Lt, class Nat, toInt, d0, d1, d2, d3, d4, d5, d6, d7, d8)
|
||||
import Prelude (($))
|
||||
import Data.Typelevel.Num
|
||||
( D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, class Lt, class Nat, toInt
|
||||
, d0, d1, d2, d3, d4, d5, d6, d7, d8)
|
||||
import Data.Generic.Rep (class Generic, Constructor (..), Argument (..), Product (..))
|
||||
import Type.RowList (Cons, Nil, kind RowList, class ListToRow)
|
||||
import Prim.Row (class Cons)
|
||||
import Prim.RowList (RowList)
|
||||
import Type.RowList (Cons, Nil, class ListToRow)
|
||||
|
||||
-- | Safely coerce a `TupleN` pair into a PureScript Tuple
|
||||
xt :: forall a b. T2 a b -> DT.Tuple a b
|
||||
xt t = DT.Tuple (prj d0 t) (prj d1 t)
|
||||
|
||||
foreign import prjImpl :: forall t a. Int -> TupleN t -> a
|
||||
-- | Safely coerce a `TupleN` pair into a PureScript Nested Tuple
|
||||
xt2 :: forall a b. T2 a b -> DTN.Tuple2 a b
|
||||
xt2 t = DTN.tuple2 (prj d0 t) (prj d1 t)
|
||||
|
||||
xt3 :: forall a b c. T3 a b c -> DTN.Tuple3 a b c
|
||||
xt3 t = DTN.tuple3 (prj d0 t) (prj d1 t) (prj d2 t)
|
||||
|
||||
xt4 :: forall a b c d. T4 a b c d -> DTN.Tuple4 a b c d
|
||||
xt4 t = DTN.tuple4 (prj d0 t) (prj d1 t) (prj d2 t) (prj d3 t)
|
||||
|
||||
xt5 :: forall a b c d e. T5 a b c d e -> DTN.Tuple5 a b c d e
|
||||
xt5 t = DTN.tuple5 (prj d0 t) (prj d1 t) (prj d2 t) (prj d3 t) (prj d4 t)
|
||||
|
||||
xt6 :: forall a b c d e f. T6 a b c d e f -> DTN.Tuple6 a b c d e f
|
||||
xt6 t = DTN.tuple6 (prj d0 t) (prj d1 t) (prj d2 t) (prj d3 t) (prj d4 t) (prj d5 t)
|
||||
|
||||
xt7 :: forall a b c d e f g. T7 a b c d e f g -> DTN.Tuple7 a b c d e f g
|
||||
xt7 t = DTN.tuple7 (prj d0 t) (prj d1 t) (prj d2 t) (prj d3 t) (prj d4 t) (prj d5 t) (prj d6 t)
|
||||
|
||||
xt8 :: forall a b c d e f g h. T8 a b c d e f g h -> DTN.Tuple8 a b c d e f g h
|
||||
xt8 t = DTN.tuple8 (prj d0 t) (prj d1 t) (prj d2 t) (prj d3 t) (prj d4 t) (prj d5 t) (prj d6 t) (prj d7 t)
|
||||
|
||||
xt9 :: forall a b c d e f g h i. T9 a b c d e f g h i -> DTN.Tuple9 a b c d e f g h i
|
||||
xt9 t = DTN.tuple9 (prj d0 t) (prj d1 t) (prj d2 t) (prj d3 t) (prj d4 t) (prj d5 t) (prj d6 t) (prj d7 t) (prj d8 t)
|
||||
|
||||
foreign import prjImpl :: forall t a. Fn2 Int (TupleN t) a
|
||||
|
||||
-- | Project a value of index `n` from a `TupleN`, using `Data.TypeLevel.Num.Reps.dN` as Nat values.
|
||||
prj :: forall t t' t'' n n' a size
|
||||
|
@ -28,12 +61,12 @@ prj :: forall t t' t'' n n' a size
|
|||
=> Cons n' a t'' t'
|
||||
=> Nat n
|
||||
=> n -> TupleN t -> a
|
||||
prj n t = prjImpl (toInt n) t
|
||||
prj n t = runFn2 prjImpl (toInt n) t
|
||||
|
||||
|
||||
|
||||
-- | Represented as a heterogeneous array under the hood
|
||||
foreign import data TupleN :: RowList -> Type
|
||||
foreign import data TupleN :: RowList Type -> Type
|
||||
|
||||
|
||||
type T2 a b =
|
||||
|
@ -53,16 +86,34 @@ type T8 a b c d e f g h =
|
|||
type T9 a b c d e f g h i =
|
||||
TupleN (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e (Cons "5" f (Cons "6" g (Cons "7" h (Cons "8" i Nil)))))))))
|
||||
|
||||
foreign import t2 :: forall a b . a -> b -> T2 a b
|
||||
foreign import t3 :: forall a b c . a -> b -> c -> T3 a b c
|
||||
foreign import t4 :: forall a b c d . a -> b -> c -> d -> T4 a b c d
|
||||
foreign import t5 :: forall a b c d e . a -> b -> c -> d -> e -> T5 a b c d e
|
||||
foreign import t6 :: forall a b c d e f . a -> b -> c -> d -> e -> f -> T6 a b c d e f
|
||||
foreign import t7 :: forall a b c d e f g . a -> b -> c -> d -> e -> f -> g -> T7 a b c d e f g
|
||||
foreign import t8 :: forall a b c d e f g h . a -> b -> c -> d -> e -> f -> g -> h -> T8 a b c d e f g h
|
||||
foreign import t9 :: forall a b c d e f g h i. a -> b -> c -> d -> e -> f -> g -> h -> i -> T9 a b c d e f g h i
|
||||
|
||||
class TupleSize n (t :: RowList) | t -> n
|
||||
t2 :: forall a b . a -> b -> T2 a b
|
||||
t2 = runFn2 t2_
|
||||
t3 :: forall a b c . a -> b -> c -> (T3 a b c)
|
||||
t3 = runFn3 t3_
|
||||
t4 :: forall a b c d . a -> b -> c -> d -> (T4 a b c d)
|
||||
t4 = runFn4 t4_
|
||||
t5 :: forall a b c d e . a -> b -> c -> d -> e -> (T5 a b c d e)
|
||||
t5 = runFn5 t5_
|
||||
t6 :: forall a b c d e f . a -> b -> c -> d -> e -> f -> (T6 a b c d e f)
|
||||
t6 = runFn6 t6_
|
||||
t7 :: forall a b c d e f g . a -> b -> c -> d -> e -> f -> g -> (T7 a b c d e f g)
|
||||
t7 = runFn7 t7_
|
||||
t8 :: forall a b c d e f g h . a -> b -> c -> d -> e -> f -> g -> h -> (T8 a b c d e f g h)
|
||||
t8 = runFn8 t8_
|
||||
t9 :: forall a b c d e f g h i. a -> b -> c -> d -> e -> f -> g -> h -> i -> (T9 a b c d e f g h i)
|
||||
t9 = runFn9 t9_
|
||||
|
||||
foreign import t2_ :: forall a b . Fn2 a b (T2 a b)
|
||||
foreign import t3_ :: forall a b c . Fn3 a b c (T3 a b c)
|
||||
foreign import t4_ :: forall a b c d . Fn4 a b c d (T4 a b c d)
|
||||
foreign import t5_ :: forall a b c d e . Fn5 a b c d e (T5 a b c d e)
|
||||
foreign import t6_ :: forall a b c d e f . Fn6 a b c d e f (T6 a b c d e f)
|
||||
foreign import t7_ :: forall a b c d e f g . Fn7 a b c d e f g (T7 a b c d e f g)
|
||||
foreign import t8_ :: forall a b c d e f g h . Fn8 a b c d e f g h (T8 a b c d e f g h)
|
||||
foreign import t9_ :: forall a b c d e f g h i. Fn9 a b c d e f g h i (T9 a b c d e f g h i)
|
||||
|
||||
class TupleSize n (t :: RowList Type) | t -> n
|
||||
|
||||
instance tupleSizeT2 :: TupleSize D2 (Cons "0" a (Cons "1" b Nil))
|
||||
instance tupleSizeT3 :: TupleSize D3 (Cons "0" a (Cons "1" b (Cons "2" c Nil)))
|
||||
|
@ -77,13 +128,13 @@ instance tupleSizeT9 :: TupleSize D9 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "
|
|||
instance genericTuple2 :: Generic
|
||||
(TupleN (Cons "0" a (Cons "1" b Nil)))
|
||||
(Constructor "t2" (Product (Argument a) (Argument b))) where
|
||||
to (Constructor (Product (Argument a) (Argument b))) = t2 a b
|
||||
to (Constructor (Product (Argument a) (Argument b))) = runFn2 t2_ a b
|
||||
from xs = Constructor (Product (Argument (prj d0 xs)) (Argument (prj d1 xs)))
|
||||
|
||||
instance genericTuple3 :: Generic
|
||||
(TupleN (Cons "0" a (Cons "1" b (Cons "2" c Nil))))
|
||||
(Constructor "t3" (Product (Argument a) (Product (Argument b) (Argument c)))) where
|
||||
to (Constructor (Product (Argument a) (Product (Argument b) (Argument c)))) = t3 a b c
|
||||
to (Constructor (Product (Argument a) (Product (Argument b) (Argument c)))) = runFn3 t3_ a b c
|
||||
from xs = Constructor $ Product (Argument (prj d0 xs)) $ Product (Argument (prj d1 xs)) (Argument (prj d2 xs))
|
||||
|
||||
instance genericTuple4 :: Generic
|
||||
|
@ -98,7 +149,7 @@ instance genericTuple4 :: Generic
|
|||
to (Constructor (Product (Argument a)
|
||||
(Product (Argument b)
|
||||
(Product (Argument c)
|
||||
(Argument d))))) = t4 a b c d
|
||||
(Argument d))))) = runFn4 t4_ a b c d
|
||||
from xs = Constructor $ Product (Argument (prj d0 xs))
|
||||
$ Product (Argument (prj d1 xs))
|
||||
$ Product (Argument (prj d2 xs))
|
||||
|
@ -119,7 +170,7 @@ instance genericTuple5 :: Generic
|
|||
(Product (Argument b)
|
||||
(Product (Argument c)
|
||||
(Product (Argument d)
|
||||
(Argument e)))))) = t5 a b c d e
|
||||
(Argument e)))))) = runFn5 t5_ a b c d e
|
||||
from xs = Constructor $ Product (Argument (prj d0 xs))
|
||||
$ Product (Argument (prj d1 xs))
|
||||
$ Product (Argument (prj d2 xs))
|
||||
|
@ -144,7 +195,7 @@ instance genericTuple6 :: Generic
|
|||
(Product (Argument c)
|
||||
(Product (Argument d)
|
||||
(Product (Argument e)
|
||||
(Argument f))))))) = t6 a b c d e f
|
||||
(Argument f))))))) = runFn6 t6_ a b c d e f
|
||||
from xs = Constructor $ Product (Argument (prj d0 xs))
|
||||
$ Product (Argument (prj d1 xs))
|
||||
$ Product (Argument (prj d2 xs))
|
||||
|
@ -173,7 +224,7 @@ instance genericTuple7 :: Generic
|
|||
(Product (Argument d)
|
||||
(Product (Argument e)
|
||||
(Product (Argument f)
|
||||
(Argument g)))))))) = t7 a b c d e f g
|
||||
(Argument g)))))))) = runFn7 t7_ a b c d e f g
|
||||
from xs = Constructor $ Product (Argument (prj d0 xs))
|
||||
$ Product (Argument (prj d1 xs))
|
||||
$ Product (Argument (prj d2 xs))
|
||||
|
@ -206,7 +257,7 @@ instance genericTuple8 :: Generic
|
|||
(Product (Argument e)
|
||||
(Product (Argument f)
|
||||
(Product (Argument g)
|
||||
(Argument h))))))))) = t8 a b c d e f g h
|
||||
(Argument h))))))))) = runFn8 t8_ a b c d e f g h
|
||||
from xs = Constructor $ Product (Argument (prj d0 xs))
|
||||
$ Product (Argument (prj d1 xs))
|
||||
$ Product (Argument (prj d2 xs))
|
||||
|
@ -243,7 +294,7 @@ instance genericTuple9 :: Generic
|
|||
(Product (Argument f)
|
||||
(Product (Argument g)
|
||||
(Product (Argument h)
|
||||
(Argument i)))))))))) = t9 a b c d e f g h i
|
||||
(Argument i)))))))))) = runFn9 t9_ a b c d e f g h i
|
||||
from xs = Constructor $ Product (Argument (prj d0 xs))
|
||||
$ Product (Argument (prj d1 xs))
|
||||
$ Product (Argument (prj d2 xs))
|
||||
|
|
5
test/Main.js
Normal file
5
test/Main.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
export function lenTupleImpl (string) {
|
||||
return [string, string.length]
|
||||
}
|
|
@ -1,12 +1,19 @@
|
|||
module Test.Main where
|
||||
|
||||
import Data.Tuple.Native (T3, prj, t3)
|
||||
import Data.Tuple.Native (T2, T3, prj, t3, xt, xt3)
|
||||
import Data.Tuple (Tuple)
|
||||
import Data.Tuple.Nested (Tuple3)
|
||||
import Data.Typelevel.Num (d0, d1, d2)
|
||||
|
||||
import Prelude (Unit, discard, ($))
|
||||
import Effect (Effect)
|
||||
import Effect.Console (logShow)
|
||||
|
||||
foreign import lenTupleImpl :: String -> T2 String Int
|
||||
|
||||
lenTuple :: String -> Tuple String Int
|
||||
lenTuple s = xt $ lenTupleImpl s
|
||||
|
||||
main :: Effect Unit
|
||||
main = do
|
||||
let x :: T3 Int Int Int
|
||||
|
@ -15,3 +22,12 @@ main = do
|
|||
logShow $ prj d0 x
|
||||
logShow $ prj d1 x
|
||||
logShow $ prj d2 x
|
||||
|
||||
let t :: Tuple3 Int Int Int
|
||||
t = xt3 x
|
||||
logShow $ t
|
||||
|
||||
-- test foreign import
|
||||
let l :: Tuple String Int
|
||||
l = lenTuple "Testing"
|
||||
logShow l
|
||||
|
|
Loading…
Reference in a new issue