├── .gitignore ├── README.md ├── build-tidy-mklens.sh ├── lenses ├── Ansi │ └── Codes │ │ └── Lens.purs ├── ArgParse │ └── Basic │ │ └── Lens.purs ├── Control │ ├── Comonad │ │ ├── Env │ │ │ ├── Lens.purs │ │ │ └── Trans │ │ │ │ └── Lens.purs │ │ ├── Store │ │ │ ├── Lens.purs │ │ │ └── Trans │ │ │ │ └── Lens.purs │ │ └── Traced │ │ │ ├── Lens.purs │ │ │ └── Trans │ │ │ └── Lens.purs │ ├── Monad │ │ ├── Cont │ │ │ ├── Lens.purs │ │ │ └── Trans │ │ │ │ └── Lens.purs │ │ ├── Except │ │ │ ├── Lens.purs │ │ │ └── Trans │ │ │ │ └── Lens.purs │ │ ├── Gen │ │ │ └── Class │ │ │ │ └── Lens.purs │ │ ├── Identity │ │ │ └── Trans │ │ │ │ └── Lens.purs │ │ ├── List │ │ │ └── Trans │ │ │ │ └── Lens.purs │ │ ├── Maybe │ │ │ └── Trans │ │ │ │ └── Lens.purs │ │ ├── RWS │ │ │ ├── Lens.purs │ │ │ └── Trans │ │ │ │ └── Lens.purs │ │ ├── Reader │ │ │ ├── Lens.purs │ │ │ └── Trans │ │ │ │ └── Lens.purs │ │ ├── Rec │ │ │ └── Class │ │ │ │ └── Lens.purs │ │ ├── State │ │ │ ├── Lens.purs │ │ │ └── Trans │ │ │ │ └── Lens.purs │ │ ├── Trampoline │ │ │ └── Lens.purs │ │ └── Writer │ │ │ ├── Lens.purs │ │ │ └── Trans │ │ │ └── Lens.purs │ └── Parallel │ │ └── Class │ │ └── Lens.purs ├── Data │ ├── Array │ │ └── ST │ │ │ └── Lens.purs │ ├── ArrayBuffer │ │ └── Types │ │ │ └── Lens.purs │ ├── Bifunctor │ │ └── Join │ │ │ └── Lens.purs │ ├── CatList │ │ └── Lens.purs │ ├── CatQueue │ │ └── Lens.purs │ ├── CodePoint │ │ └── Unicode │ │ │ ├── Internal │ │ │ ├── Casing │ │ │ │ └── Lens.purs │ │ │ └── Lens.purs │ │ │ └── Lens.purs │ ├── Comparison │ │ └── Lens.purs │ ├── Const │ │ └── Lens.purs │ ├── Date │ │ └── Component │ │ │ └── Lens.purs │ ├── DateTime │ │ └── Lens.purs │ ├── Either │ │ ├── Lens.purs │ │ └── Nested │ │ │ └── Lens.purs │ ├── Enum │ │ └── Lens.purs │ ├── Equivalence │ │ └── Lens.purs │ ├── Function │ │ └── Uncurried │ │ │ └── Lens.purs │ ├── Functor │ │ ├── App │ │ │ └── Lens.purs │ │ ├── Clown │ │ │ └── Lens.purs │ │ ├── Compose │ │ │ └── Lens.purs │ │ ├── Coproduct │ │ │ ├── Lens.purs │ │ │ └── Nested │ │ │ │ └── Lens.purs │ │ ├── Costar │ │ │ └── Lens.purs │ │ ├── Flip │ │ │ └── Lens.purs │ │ ├── Joker │ │ │ └── Lens.purs │ │ ├── Product │ │ │ ├── Lens.purs │ │ │ └── Nested │ │ │ │ └── Lens.purs │ │ └── Product2 │ │ │ └── Lens.purs │ ├── Generic │ │ └── Rep │ │ │ └── Lens.purs │ ├── Identity │ │ └── Lens.purs │ ├── Int │ │ └── Lens.purs │ ├── Interval │ │ ├── Duration │ │ │ ├── Iso │ │ │ │ └── Lens.purs │ │ │ └── Lens.purs │ │ └── Lens.purs │ ├── Lens │ │ └── Internal │ │ │ ├── Exchange │ │ │ └── Lens.purs │ │ │ ├── Focusing │ │ │ └── Lens.purs │ │ │ ├── Forget │ │ │ └── Lens.purs │ │ │ ├── Grating │ │ │ └── Lens.purs │ │ │ ├── Indexed │ │ │ └── Lens.purs │ │ │ ├── Market │ │ │ └── Lens.purs │ │ │ ├── Re │ │ │ └── Lens.purs │ │ │ ├── Shop │ │ │ └── Lens.purs │ │ │ ├── Stall │ │ │ └── Lens.purs │ │ │ ├── Tagged │ │ │ └── Lens.purs │ │ │ └── Zipping │ │ │ └── Lens.purs │ ├── List │ │ ├── Lazy │ │ │ ├── Lens.purs │ │ │ └── Types │ │ │ │ └── Lens.purs │ │ ├── Lens.purs │ │ ├── Types │ │ │ └── Lens.purs │ │ └── ZipList │ │ │ └── Lens.purs │ ├── Map │ │ └── Lens.purs │ ├── Maybe │ │ ├── First │ │ │ └── Lens.purs │ │ ├── Last │ │ │ └── Lens.purs │ │ └── Lens.purs │ ├── Monoid │ │ └── Alternate │ │ │ └── Lens.purs │ ├── NaturalTransformation │ │ └── Lens.purs │ ├── NonEmpty │ │ └── Lens.purs │ ├── Op │ │ └── Lens.purs │ ├── Ord │ │ ├── Down │ │ │ └── Lens.purs │ │ ├── Max │ │ │ └── Lens.purs │ │ └── Min │ │ │ └── Lens.purs │ ├── Ordering │ │ └── Lens.purs │ ├── Posix │ │ ├── Lens.purs │ │ └── Signal │ │ │ └── Lens.purs │ ├── Predicate │ │ └── Lens.purs │ ├── Profunctor │ │ ├── Join │ │ │ └── Lens.purs │ │ └── Star │ │ │ └── Lens.purs │ ├── String │ │ ├── CaseInsensitive │ │ │ └── Lens.purs │ │ ├── NonEmpty │ │ │ └── CaseInsensitive │ │ │ │ └── Lens.purs │ │ ├── Pattern │ │ │ └── Lens.purs │ │ └── Regex │ │ │ └── Flags │ │ │ └── Lens.purs │ ├── Symbol │ │ └── Lens.purs │ ├── Time │ │ ├── Duration │ │ │ └── Lens.purs │ │ └── Lens.purs │ ├── Traversable │ │ └── Accum │ │ │ └── Lens.purs │ └── Tuple │ │ ├── Lens.purs │ │ └── Nested │ │ └── Lens.purs ├── Dodo │ ├── Internal │ │ └── Lens.purs │ └── Lens.purs ├── Effect │ ├── AVar │ │ └── Lens.purs │ └── Aff │ │ ├── Compat │ │ └── Lens.purs │ │ └── Lens.purs ├── Foreign │ └── Lens.purs ├── Math │ └── Lens.purs ├── Node │ ├── Buffer │ │ └── Types │ │ │ └── Lens.purs │ ├── ChildProcess │ │ └── Lens.purs │ ├── Encoding │ │ └── Lens.purs │ ├── FS │ │ ├── Async │ │ │ └── Lens.purs │ │ ├── Lens.purs │ │ ├── Stats │ │ │ └── Lens.purs │ │ └── Stream │ │ │ └── Lens.purs │ ├── Path │ │ └── Lens.purs │ ├── Platform │ │ └── Lens.purs │ └── Stream │ │ └── Lens.purs ├── PureScript │ └── CST │ │ ├── Errors │ │ └── Lens.purs │ │ ├── Layout │ │ └── Lens.purs │ │ ├── Lens.purs │ │ ├── ModuleGraph │ │ └── Lens.purs │ │ ├── Parser │ │ ├── Lens.purs │ │ └── Monad │ │ │ └── Lens.purs │ │ ├── Print │ │ └── Lens.purs │ │ ├── Range │ │ └── TokenList │ │ │ └── Lens.purs │ │ ├── TokenStream │ │ └── Lens.purs │ │ ├── Traversal │ │ └── Lens.purs │ │ └── Types │ │ └── Lens.purs ├── RecordLens.purs ├── Tidy │ ├── Codegen │ │ ├── Class │ │ │ └── Lens.purs │ │ ├── Lens.purs │ │ ├── Monad │ │ │ └── Lens.purs │ │ └── Types │ │ │ └── Lens.purs │ ├── Doc │ │ └── Lens.purs │ ├── Hang │ │ └── Lens.purs │ ├── Lens.purs │ ├── Precedence │ │ └── Lens.purs │ └── Token │ │ └── Lens.purs └── Type │ ├── Data │ ├── Boolean │ │ └── Lens.purs │ ├── Ordering │ │ └── Lens.purs │ ├── Row │ │ └── Lens.purs │ └── RowList │ │ └── Lens.purs │ ├── Function │ └── Lens.purs │ ├── Proxy │ └── Lens.purs │ └── Row │ └── Lens.purs ├── packages.dhall ├── regen-lenses.sh ├── regen-snapshots.sh ├── snapshots.dhall ├── snapshots ├── CheckOpenImports │ ├── Reimport.purs │ ├── Reimport │ │ └── Lens.purs │ ├── Remove.purs │ ├── Remove │ │ └── Lens.purs │ ├── RemoveHiding.purs │ └── RemoveHiding │ │ └── Lens.purs ├── Imports │ ├── ImportedExplicitTypesNoModuleAlias.purs │ ├── ImportedExplicitTypesWithModuleAlias.purs │ ├── ModuleAliasOnly.purs │ ├── OpenImportNameClashes.purs │ └── SharedModuleAlias.purs ├── PrimaryExample.purs ├── PrimaryExample │ └── Lens.purs ├── UseAbcLabelStyle.purs ├── UseAbcLabelStyle │ └── Lens.purs ├── UseArgLabelStyle.purs ├── UseArgLabelStyle │ └── Lens.purs ├── UseGlobalPropFile │ ├── GlobalRecordLens.purs │ ├── Module1.purs │ └── Module2.purs ├── UseLabelPrefix.purs ├── UseLabelPrefix │ └── Lens.purs ├── UseLocalProps │ ├── Module1.purs │ ├── Module1 │ │ └── Lens.purs │ ├── Module2.purs │ └── Module2 │ │ └── Lens.purs ├── UseNoLabelPrefix.purs ├── UseNoLabelPrefix │ └── Lens.purs ├── UseTypeAliases.purs └── UseTypeAliases │ └── Lens.purs ├── spago.dhall ├── src ├── CLI.purs ├── Main.purs ├── MkDir.js ├── MkDir.purs ├── MkLens.purs ├── Types.purs └── Version.purs ├── test └── Main.purs └── tidy-mklens.js /.gitignore: -------------------------------------------------------------------------------- 1 | /bower_components/ 2 | /node_modules/ 3 | /.pulp-cache/ 4 | /output/ 5 | /output-snapshots/ 6 | /generated-docs/ 7 | /.psc-package/ 8 | /.psc* 9 | /.purs* 10 | /.psa* 11 | /.spago 12 | tidy-mklens -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # purescript-tidy-codegen-lens 2 | 3 | Generate lenses and prisms for your data types automatically. 4 | 5 | An input file, `./Foo.purs`, will generate an output file `./Foo/Lens.purs` if `Foo.purs` contains any type declarations. 6 | 7 | This is currently a WIP. 8 | 9 | ## Usage 10 | 11 | For testing a local version, run `spago build` and then `./tidy-mklens.js `. To build a bundled one, use `./build-tidy-mklens.sh`. 12 | 13 | ``` 14 | $ ./tidy-mklens.js --help 15 | tidy-mklens 16 | A CLI for generating optics for your data types 17 | 18 | Expected usage: 19 | tidy-mklens [OPTIONS] PURS_GLOBS... 20 | 21 | Examples: 22 | tidy-mklens src 23 | tidy-mklens --global-record-lens-module RecordLens src 24 | tidy-mklens --label-style-abc src 25 | tidy-mklens --gen-type-alias-lenses src 26 | tidy-mklens --output-dir src .spago/*/*/src/**/*.purs:4 27 | 28 | --gen-type-alias-isos,-t Generate isos for type aliases 29 | --global-record-lens-module,-m MODULE_PATH The full module path to use for the single record label lenses file 30 | (e.g `Foo.Bar.Lens`). The module will be outtputed to a file based 31 | on the module path (e.g. `Foo.Bar.Lens` will be saved to 32 | `/Foo/Bar/Lens.purs`). 33 | --help,-h Show this help message. 34 | --label-prefix,-l PREFIX Use `_PREFIXFoo` for the lens for a record '{ foo :: a }' 35 | --label-prefix-none,-n Use '_foo' for the lens for a record '{ foo :: a }' 36 | --label-style-abc,-b Data constructors with 3+ args will use record labels based on the alphabet (e.g. 'a', 'b', ..., 'z', 'aa', 'ab', ...) 37 | --label-style-arg,-a Data constructors with 3+ args will use record labels of 'argN' (e.g. 'arg1', 'arg2', ..., 'argN') 38 | --output-dir,-o The directory into which to write the generated files 39 | (defaults to `src`). 40 | --version,-v Shows the current version 41 | 42 | GLOB[:DIR_STRIP_COUNT] Globs for PureScript sources (e.g. `src` `test/**/*.purs`) 43 | and the number of root directories to strip from each file 44 | path (defaults to 1) that are separated by the OS-specific 45 | path delimiter (POSIX: ':', Windows: ';') 46 | ``` 47 | 48 | ## Examples 49 | 50 | The table illustrates some of the CLI args above via the current output on the files stored in the [snapshots folder](./snapshots). You can verify that these compile via `spago -x snapshots.dhall build --purs-args "--output output-snapshots"`. 51 | 52 | | Purpose | Files | 53 | | - | - | 54 | | Show the 'arg' label style | | 55 | | Show the 'abc' label style | | 56 | | Show the `--gen-type-alias-isos` option | | 57 | | Show the `--label-prefix-none` option | | 58 | | Show the `--label-prefix "prop"` option (default) | | 59 | | The record label lenses will be duplicated in each module. This is why the `--gen-record-lens-*` options exist | | 60 | | Demo the `--gen-record-lens-*` options | | 61 | | Primary example | | 62 | 63 | Files were generated using the below commands, which are stored in [regen-snapshots.sh](./regen-snapshots.sh): 64 | 65 | ```bash 66 | # Note: the `arg` style is the default 67 | ./tidy-mklens.js --label-style-arg --output-dir snapshots snapshots/UseArgLabelStyle.purs 68 | 69 | ./tidy-mklens.js --label-style-abc --output-dir snapshots snapshots/UseAbcLabelStyle.purs 70 | 71 | # Can optionally generate lenses for type aliases 72 | # Useful when just getting familiar with a library and type signatures 73 | # and typed holes are all you have 74 | ./tidy-mklens.js --gen-type-alias-isos --output-dir snapshots snapshots/UseTypeAliases.purs 75 | 76 | # By default, any record labels referenced in your types will 77 | # have their corresponding lense generated using the style 78 | # `_propLabelName`. You can swap out 'prop' for your own 79 | # custom prefix... 80 | ./tidy-mklens.js --label-prefix "prop" --output-dir snapshots snapshots/UseLabelPrefix.purs 81 | 82 | # ... or none at all (e.g. `_labelName`). 83 | ./tidy-mklens.js --label-prefix-none --output-dir snapshots snapshots/UseNoLabelPrefix.purs 84 | 85 | # If the same label is used in multiple types, 86 | # a lens for that label will be stored in each file, 87 | # thereby duplicating the lens. This can lead to 88 | # import frency. 89 | 90 | ./tidy-mklens.js --output-dir snapshots snapshots/UseLocalProps/ 91 | 92 | # One way around this is to generate a single file 93 | # that stores all lenses for the deduplicated labels, 94 | # ensuring that label lenses are only imported from 95 | # one place. 96 | ./tidy-mklens.js \ 97 | --output-dir snapshots \ 98 | --global-record-lens-module UseGlobalPropFile.GlobalRecordLens \ 99 | snapshots/UseGlobalPropFile 100 | 101 | # Here's the primary example, showing the full power of the code 102 | ./tidy-mklens.js --gen-type-alias-isos --output-dir snapshots snapshots/PrimaryExample.purs 103 | 104 | # Open imports aren't always handled correctly. See these snapshots 105 | ./tidy-mklens.js --output-dir snapshots snapshots/CheckOpenImports 106 | ``` 107 | 108 | ### Explaining the `GLOB[:DIR_STRIP_COUNT]` arg 109 | 110 | The generated file's file path is based on the input file's file path. Most of the time, one will use this program to generate optics for the `src` directory. However, in monorepos, there may be multiple directories that contains PureScript source code. This feature exists to account for those use cases. 111 | 112 | The `glob:` indicates how many parent directories, starting from the file's relative path's root, to strip from the outputted file's file path. When not specified, the `DIR_STIP_COUNT` defaults to `1`. 113 | 114 | For example, let's say the `src` directory has the following structure: 115 | ``` 116 | /src 117 | /Foo 118 | /Bar.purs 119 | ``` 120 | 121 | Running `./tidy-mklens.js --output-dir lenses src:X` where `X` is one of the integers listed in the below table will produce the corresponding output: 122 | 123 | | X | Output file | Explanation | 124 | | - | - | - | 125 | | 1
(default) | `lenses/Foo/Bar/Lens.purs` | the `src` segment was removed | 126 | | 2 | `lenses/Bar/Lens.purs` | the `src` and `Foo` segments were removed | 127 | | 3 | `lenses/Lens.purs` | the `src`, `Foo`, and `Bar` segments were removed | 128 | | 4 | `lenses/Lens.purs` | Since there are only 3 segments available, this is no different than when X is 3 | 129 | 130 | This feature enables one to run this program against all of a projects dependencies (as stored in the `.spago` folder) and output the results into a new folder. This can be accomplished via the glob `.spago/*/*/src/**/*.purs:4`, which says, "If you come across a file `.spago/packageName/version/src/Foo/Bar.purs`, strip the first four root directories (e.g. `.spago/packageName/version/src`), and append the result (e.g. `Foo/Bar.purs`) to the output directory (e.g. `/Foo/Bar.purs`). 131 | 132 | For example, the `lenses` folder contains the output of running this command, which is stored in [regen-lenses.sh](./regen-lenses.sh): 133 | ```sh 134 | ./tidy-mklens.js \ 135 | --output-dir lenses \ 136 | --gen-type-alias-isos \ 137 | --label-prefix-none \ 138 | --global-record-lens-module Dependencies.RecordLens \ 139 | .spago/*/*/src/**/*.purs:4 140 | ``` 141 | 142 | ## Assumptions 143 | 144 | **In general, the generated `Lens.purs` file(s) will compile so long as the source file compiles and does not contain any warnings regarding your imports. However, the generated file may produce compiler warnings.** 145 | 146 | `tidy-mklens` uses limited information to generate a `Lens.purs` file. There are some ambiguous situations it cannot handle without more information (e.g. type checking). 147 | 148 | More specifically, the generated `Lens.purs` file will compile if the following is true about your source file: 149 | ```purescript 150 | module ModuleName where 151 | 152 | -- Assumption #1: 153 | -- To ensure types referenced in the source file's types are imported 154 | -- in the generated file, always re-import all open imports. 155 | -- 156 | -- If the types referenced in the source file's types are from imports, 157 | -- the generated file will not compile unless they are imported 158 | -- in the generated file, too. 159 | -- 160 | -- However, this will produce compiler warnings in the generated file 161 | -- if the open imports' members aren't used. 162 | -- `tidy-mklens` can't know what these modules import 163 | -- and thus whether they would be used in the generated file. 164 | -- 165 | -- Note: the compiler warns if 2+ open imports are used. 166 | import Prelude 167 | import SomethingElse 168 | import MyModule hiding (someMember) 169 | 170 | -- Assumption #2: 171 | -- Each module alias to an open import refers to at most one module. 172 | -- 173 | -- Without this constraint, `tidy-mklens` cannot know which module 174 | -- (e.g. `Module1` or `Module2`) to import in the generated file. 175 | -- 176 | -- Note: the compiler warns if an alias refers to 2+ open imports. 177 | import ImportWithModuleAlias as ThisIsOk 178 | import SomeModule hiding (someMember) as ThisIsAlsoOk 179 | import Module1 as ThisIsBadBecauseItRefersToMultipleModules 180 | import Module2 as ThisIsBadBecauseItRefersToMultipleModules 181 | 182 | -- That being said, module aliases to closed imports are ok, 183 | -- even if one alias refers to the multipe modules. 184 | -- 185 | -- All usages of such members will use the qualified notation 186 | -- for them (e.g. `Mod.Type1`), so `tidy-mklens` can determine 187 | -- which module to import to ensure that type is included 188 | -- in the generated `Lens.purs` file. 189 | import ModuleA (Type1, Type2) as Mod 190 | import ModuleB (Type3, Type4) as Mod 191 | 192 | -- Explicit imports work fine without issues 193 | import ModuleWithExplicitExports (Foo, bar, baz) 194 | ``` 195 | -------------------------------------------------------------------------------- /build-tidy-mklens.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Simple script for regenerating the `tidy-mklens` executable script. 4 | 5 | set -x 6 | 7 | spago bundle-app -m Main -t out 8 | 9 | echo '#!/usr/bin/env node' > tidy-mklens 10 | cat out >> tidy-mklens 11 | chmod +x tidy-mklens 12 | rm out 13 | -------------------------------------------------------------------------------- /lenses/Ansi/Codes/Lens.purs: -------------------------------------------------------------------------------- 1 | module Ansi.Codes.Lens where 2 | 3 | import Prelude 4 | 5 | import Ansi.Codes (Color(..), EraseParam(..), EscapeCode(..), GraphicsParam(..), RenderingMode(..)) 6 | import Data.Either (Either(..)) 7 | import Data.Lens.Prism (Prism', prism) 8 | import Data.List.NonEmpty (NonEmptyList) 9 | import Data.Tuple (Tuple(..)) 10 | import Prelude (Unit, const, unit) 11 | 12 | _Up :: Prism' EscapeCode Int 13 | _Up = prism Up case _ of 14 | Up a -> Right a 15 | other -> Left other 16 | 17 | _Down :: Prism' EscapeCode Int 18 | _Down = prism Down case _ of 19 | Down a -> Right a 20 | other -> Left other 21 | 22 | _Forward :: Prism' EscapeCode Int 23 | _Forward = prism Forward case _ of 24 | Forward a -> Right a 25 | other -> Left other 26 | 27 | _Back :: Prism' EscapeCode Int 28 | _Back = prism Back case _ of 29 | Back a -> Right a 30 | other -> Left other 31 | 32 | _NextLine :: Prism' EscapeCode Int 33 | _NextLine = prism NextLine case _ of 34 | NextLine a -> Right a 35 | other -> Left other 36 | 37 | _PreviousLine :: Prism' EscapeCode Int 38 | _PreviousLine = prism PreviousLine case _ of 39 | PreviousLine a -> Right a 40 | other -> Left other 41 | 42 | _HorizontalAbsolute :: Prism' EscapeCode Int 43 | _HorizontalAbsolute = prism HorizontalAbsolute case _ of 44 | HorizontalAbsolute a -> Right a 45 | other -> Left other 46 | 47 | _Position :: Prism' EscapeCode (Tuple Int Int) 48 | _Position = prism (\(Tuple a b) -> Position a b) case _ of 49 | Position a b -> Right (Tuple a b) 50 | other -> Left other 51 | 52 | _EraseData :: Prism' EscapeCode EraseParam 53 | _EraseData = prism EraseData case _ of 54 | EraseData a -> Right a 55 | other -> Left other 56 | 57 | _EraseLine :: Prism' EscapeCode EraseParam 58 | _EraseLine = prism EraseLine case _ of 59 | EraseLine a -> Right a 60 | other -> Left other 61 | 62 | _ScrollUp :: Prism' EscapeCode Int 63 | _ScrollUp = prism ScrollUp case _ of 64 | ScrollUp a -> Right a 65 | other -> Left other 66 | 67 | _ScrollDown :: Prism' EscapeCode Int 68 | _ScrollDown = prism ScrollDown case _ of 69 | ScrollDown a -> Right a 70 | other -> Left other 71 | 72 | _Graphics :: Prism' EscapeCode (NonEmptyList GraphicsParam) 73 | _Graphics = prism Graphics case _ of 74 | Graphics a -> Right a 75 | other -> Left other 76 | 77 | _SavePosition :: Prism' EscapeCode Unit 78 | _SavePosition = prism (const SavePosition) case _ of 79 | SavePosition -> Right unit 80 | other -> Left other 81 | 82 | _RestorePosition :: Prism' EscapeCode Unit 83 | _RestorePosition = prism (const RestorePosition) case _ of 84 | RestorePosition -> Right unit 85 | other -> Left other 86 | 87 | _QueryPosition :: Prism' EscapeCode Unit 88 | _QueryPosition = prism (const QueryPosition) case _ of 89 | QueryPosition -> Right unit 90 | other -> Left other 91 | 92 | _HideCursor :: Prism' EscapeCode Unit 93 | _HideCursor = prism (const HideCursor) case _ of 94 | HideCursor -> Right unit 95 | other -> Left other 96 | 97 | _ShowCursor :: Prism' EscapeCode Unit 98 | _ShowCursor = prism (const ShowCursor) case _ of 99 | ShowCursor -> Right unit 100 | other -> Left other 101 | 102 | _ToEnd :: Prism' EraseParam Unit 103 | _ToEnd = prism (const ToEnd) case _ of 104 | ToEnd -> Right unit 105 | other -> Left other 106 | 107 | _FromBeginning :: Prism' EraseParam Unit 108 | _FromBeginning = prism (const FromBeginning) case _ of 109 | FromBeginning -> Right unit 110 | other -> Left other 111 | 112 | _Entire :: Prism' EraseParam Unit 113 | _Entire = prism (const Entire) case _ of 114 | Entire -> Right unit 115 | other -> Left other 116 | 117 | _Reset :: Prism' GraphicsParam Unit 118 | _Reset = prism (const Reset) case _ of 119 | Reset -> Right unit 120 | other -> Left other 121 | 122 | _PMode :: Prism' GraphicsParam RenderingMode 123 | _PMode = prism PMode case _ of 124 | PMode a -> Right a 125 | other -> Left other 126 | 127 | _PForeground :: Prism' GraphicsParam Color 128 | _PForeground = prism PForeground case _ of 129 | PForeground a -> Right a 130 | other -> Left other 131 | 132 | _PBackground :: Prism' GraphicsParam Color 133 | _PBackground = prism PBackground case _ of 134 | PBackground a -> Right a 135 | other -> Left other 136 | 137 | _Bold :: Prism' RenderingMode Unit 138 | _Bold = prism (const Bold) case _ of 139 | Bold -> Right unit 140 | other -> Left other 141 | 142 | _Dim :: Prism' RenderingMode Unit 143 | _Dim = prism (const Dim) case _ of 144 | Dim -> Right unit 145 | other -> Left other 146 | 147 | _Italic :: Prism' RenderingMode Unit 148 | _Italic = prism (const Italic) case _ of 149 | Italic -> Right unit 150 | other -> Left other 151 | 152 | _Underline :: Prism' RenderingMode Unit 153 | _Underline = prism (const Underline) case _ of 154 | Underline -> Right unit 155 | other -> Left other 156 | 157 | _Inverse :: Prism' RenderingMode Unit 158 | _Inverse = prism (const Inverse) case _ of 159 | Inverse -> Right unit 160 | other -> Left other 161 | 162 | _Strikethrough :: Prism' RenderingMode Unit 163 | _Strikethrough = prism (const Strikethrough) case _ of 164 | Strikethrough -> Right unit 165 | other -> Left other 166 | 167 | _Black :: Prism' Color Unit 168 | _Black = prism (const Black) case _ of 169 | Black -> Right unit 170 | other -> Left other 171 | 172 | _Red :: Prism' Color Unit 173 | _Red = prism (const Red) case _ of 174 | Red -> Right unit 175 | other -> Left other 176 | 177 | _Green :: Prism' Color Unit 178 | _Green = prism (const Green) case _ of 179 | Green -> Right unit 180 | other -> Left other 181 | 182 | _Yellow :: Prism' Color Unit 183 | _Yellow = prism (const Yellow) case _ of 184 | Yellow -> Right unit 185 | other -> Left other 186 | 187 | _Blue :: Prism' Color Unit 188 | _Blue = prism (const Blue) case _ of 189 | Blue -> Right unit 190 | other -> Left other 191 | 192 | _Magenta :: Prism' Color Unit 193 | _Magenta = prism (const Magenta) case _ of 194 | Magenta -> Right unit 195 | other -> Left other 196 | 197 | _Cyan :: Prism' Color Unit 198 | _Cyan = prism (const Cyan) case _ of 199 | Cyan -> Right unit 200 | other -> Left other 201 | 202 | _White :: Prism' Color Unit 203 | _White = prism (const White) case _ of 204 | White -> Right unit 205 | other -> Left other 206 | 207 | _BrightBlack :: Prism' Color Unit 208 | _BrightBlack = prism (const BrightBlack) case _ of 209 | BrightBlack -> Right unit 210 | other -> Left other 211 | 212 | _BrightRed :: Prism' Color Unit 213 | _BrightRed = prism (const BrightRed) case _ of 214 | BrightRed -> Right unit 215 | other -> Left other 216 | 217 | _BrightGreen :: Prism' Color Unit 218 | _BrightGreen = prism (const BrightGreen) case _ of 219 | BrightGreen -> Right unit 220 | other -> Left other 221 | 222 | _BrightYellow :: Prism' Color Unit 223 | _BrightYellow = prism (const BrightYellow) case _ of 224 | BrightYellow -> Right unit 225 | other -> Left other 226 | 227 | _BrightBlue :: Prism' Color Unit 228 | _BrightBlue = prism (const BrightBlue) case _ of 229 | BrightBlue -> Right unit 230 | other -> Left other 231 | 232 | _BrightMagenta :: Prism' Color Unit 233 | _BrightMagenta = prism (const BrightMagenta) case _ of 234 | BrightMagenta -> Right unit 235 | other -> Left other 236 | 237 | _BrightCyan :: Prism' Color Unit 238 | _BrightCyan = prism (const BrightCyan) case _ of 239 | BrightCyan -> Right unit 240 | other -> Left other 241 | 242 | _BrightWhite :: Prism' Color Unit 243 | _BrightWhite = prism (const BrightWhite) case _ of 244 | BrightWhite -> Right unit 245 | other -> Left other 246 | -------------------------------------------------------------------------------- /lenses/ArgParse/Basic/Lens.purs: -------------------------------------------------------------------------------- 1 | module ArgParse.Basic.Lens where 2 | 3 | import Prelude 4 | 5 | import ArgParse.Basic (ArgError(..), ArgErrorMsg(..), ArgHelp(..)) 6 | import Data.Either (Either(..)) 7 | import Data.Lens (Lens') 8 | import Data.Lens.Iso (iso) 9 | import Data.Lens.Prism (Prism', prism) 10 | import Data.List (List) 11 | import Data.Tuple (Tuple(..)) 12 | import Prelude (Unit, const, unit) 13 | 14 | _HelpFlag :: Prism' ArgHelp (Tuple (Array String) String) 15 | _HelpFlag = prism (\(Tuple a b) -> HelpFlag a b) case _ of 16 | HelpFlag a b -> Right (Tuple a b) 17 | other -> Left other 18 | 19 | _HelpAny :: Prism' ArgHelp String 20 | _HelpAny = prism HelpAny case _ of 21 | HelpAny a -> Right a 22 | other -> Left other 23 | 24 | _HelpFormat :: Prism' ArgHelp (Tuple String ArgHelp) 25 | _HelpFormat = prism (\(Tuple a b) -> HelpFormat a b) case _ of 26 | HelpFormat a b -> Right (Tuple a b) 27 | other -> Left other 28 | 29 | _HelpArgs :: Prism' ArgHelp (Array ArgHelp) 30 | _HelpArgs = prism HelpArgs case _ of 31 | HelpArgs a -> Right a 32 | other -> Left other 33 | 34 | _HelpChoose :: Prism' ArgHelp (Tuple String (Array ArgHelp)) 35 | _HelpChoose = prism (\(Tuple a b) -> HelpChoose a b) case _ of 36 | HelpChoose a b -> Right (Tuple a b) 37 | other -> Left other 38 | 39 | _HelpCommand :: Prism' ArgHelp { arg1 :: (Array String), arg2 :: String, arg3 :: ArgHelp } 40 | _HelpCommand = prism (\{ arg1, arg2, arg3 } -> HelpCommand arg1 arg2 arg3) case _ of 41 | HelpCommand arg1 arg2 arg3 -> Right { arg1: arg1, arg2: arg2, arg3: arg3 } 42 | other -> Left other 43 | 44 | _HelpRest :: Prism' ArgHelp String 45 | _HelpRest = prism HelpRest case _ of 46 | HelpRest a -> Right a 47 | other -> Left other 48 | 49 | _ArgError :: Lens' ArgError (Tuple (List ArgHelp) ArgErrorMsg) 50 | _ArgError = iso (\(ArgError a b) -> Tuple a b) \(Tuple a b) -> ArgError a b 51 | 52 | _ExpectedFlag :: Prism' ArgErrorMsg Unit 53 | _ExpectedFlag = prism (const ExpectedFlag) case _ of 54 | ExpectedFlag -> Right unit 55 | other -> Left other 56 | 57 | _ExpectedArgValue :: Prism' ArgErrorMsg Unit 58 | _ExpectedArgValue = prism (const ExpectedArgValue) case _ of 59 | ExpectedArgValue -> Right unit 60 | other -> Left other 61 | 62 | _ExpectedRest :: Prism' ArgErrorMsg Unit 63 | _ExpectedRest = prism (const ExpectedRest) case _ of 64 | ExpectedRest -> Right unit 65 | other -> Left other 66 | 67 | _ExpectedArg :: Prism' ArgErrorMsg Unit 68 | _ExpectedArg = prism (const ExpectedArg) case _ of 69 | ExpectedArg -> Right unit 70 | other -> Left other 71 | 72 | _DuplicateArg :: Prism' ArgErrorMsg Unit 73 | _DuplicateArg = prism (const DuplicateArg) case _ of 74 | DuplicateArg -> Right unit 75 | other -> Left other 76 | 77 | _UnformatFailed :: Prism' ArgErrorMsg String 78 | _UnformatFailed = prism UnformatFailed case _ of 79 | UnformatFailed a -> Right a 80 | other -> Left other 81 | 82 | _UnknownArg :: Prism' ArgErrorMsg String 83 | _UnknownArg = prism UnknownArg case _ of 84 | UnknownArg a -> Right a 85 | other -> Left other 86 | 87 | _ShowHelp :: Prism' ArgErrorMsg Unit 88 | _ShowHelp = prism (const ShowHelp) case _ of 89 | ShowHelp -> Right unit 90 | other -> Left other 91 | 92 | _ShowInfo :: Prism' ArgErrorMsg String 93 | _ShowInfo = prism ShowInfo case _ of 94 | ShowInfo a -> Right a 95 | other -> Left other 96 | -------------------------------------------------------------------------------- /lenses/Control/Comonad/Env/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Comonad.Env.Lens where 2 | 3 | import Control.Comonad.Env (Env) 4 | import Control.Comonad.Env.Trans (EnvT) 5 | import Data.Identity (Identity) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _Env :: forall e. Iso' (Env e) (EnvT e Identity) 10 | _Env = identity 11 | -------------------------------------------------------------------------------- /lenses/Control/Comonad/Env/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Comonad.Env.Trans.Lens where 2 | 3 | import Control.Comonad.Env.Trans (EnvT) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Tuple (Tuple) 7 | 8 | _EnvT :: forall e w a. Lens' (EnvT e w a) (Tuple e (w a)) 9 | _EnvT = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Control/Comonad/Store/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Comonad.Store.Lens where 2 | 3 | import Control.Comonad.Store (Store) 4 | import Control.Comonad.Store.Trans (StoreT) 5 | import Data.Identity (Identity) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _Store :: forall s. Iso' (Store s) (StoreT s Identity) 10 | _Store = identity 11 | -------------------------------------------------------------------------------- /lenses/Control/Comonad/Store/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Comonad.Store.Trans.Lens where 2 | 3 | import Control.Comonad.Store.Trans (StoreT) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Tuple (Tuple) 7 | 8 | _StoreT :: forall s w a. Lens' (StoreT s w a) (Tuple (w (s -> a)) s) 9 | _StoreT = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Control/Comonad/Traced/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Comonad.Traced.Lens where 2 | 3 | import Control.Comonad.Traced (Traced) 4 | import Control.Comonad.Traced.Trans (TracedT) 5 | import Data.Identity (Identity) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _Traced :: forall m. Iso' (Traced m) (TracedT m Identity) 10 | _Traced = identity 11 | -------------------------------------------------------------------------------- /lenses/Control/Comonad/Traced/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Comonad.Traced.Trans.Lens where 2 | 3 | import Control.Comonad.Traced.Trans (TracedT) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _TracedT :: forall t w a. Lens' (TracedT t w a) (w (t -> a)) 8 | _TracedT = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Cont/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Cont.Lens where 2 | 3 | import Control.Monad.Cont (Cont) 4 | import Control.Monad.Cont.Trans (ContT) 5 | import Data.Identity (Identity) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _Cont :: forall r. Iso' (Cont r) (ContT r Identity) 10 | _Cont = identity 11 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Cont/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Cont.Trans.Lens where 2 | 3 | import Control.Monad.Cont.Trans (ContT) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _ContT :: forall r m a. Lens' (ContT r m a) ((a -> m r) -> m r) 8 | _ContT = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Except/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Except.Lens where 2 | 3 | import Control.Monad.Except (Except) 4 | import Control.Monad.Except.Trans (ExceptT) 5 | import Data.Identity (Identity) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _Except :: forall e. Iso' (Except e) (ExceptT e Identity) 10 | _Except = identity 11 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Except/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Except.Trans.Lens where 2 | 3 | import Control.Monad.Except.Trans (ExceptT) 4 | import Data.Either (Either) 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso.Newtype (_Newtype) 7 | 8 | _ExceptT :: forall e m a. Lens' (ExceptT e m a) (m (Either e a)) 9 | _ExceptT = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Gen/Class/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Gen.Class.Lens where 2 | 3 | import Prelude 4 | 5 | import Control.Monad.Gen.Class (Size) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _Size :: Iso' Size Int 10 | _Size = identity 11 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Identity/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Identity.Trans.Lens where 2 | 3 | import Control.Monad.Identity.Trans (IdentityT) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _IdentityT :: forall m a. Lens' (IdentityT m a) (m a) 8 | _IdentityT = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Control/Monad/List/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.List.Trans.Lens where 2 | 3 | import Control.Monad.List.Trans (ListT, Step(..)) 4 | import Data.Either (Either(..)) 5 | import Data.Lazy (Lazy) 6 | import Data.Lens (Lens') 7 | import Data.Lens.Iso.Newtype (_Newtype) 8 | import Data.Lens.Prism (Prism', prism) 9 | import Data.Tuple (Tuple(..)) 10 | import Prelude (Unit, const, unit) 11 | 12 | _ListT :: forall f a. Lens' (ListT f a) (f (Step a (ListT f a))) 13 | _ListT = _Newtype 14 | 15 | _Yield :: forall a s. Prism' (Step a s) (Tuple a (Lazy s)) 16 | _Yield = prism (\(Tuple a b) -> Yield a b) case _ of 17 | Yield a b -> Right (Tuple a b) 18 | other -> Left other 19 | 20 | _Skip :: forall a s. Prism' (Step a s) (Lazy s) 21 | _Skip = prism Skip case _ of 22 | Skip a -> Right a 23 | other -> Left other 24 | 25 | _Done :: forall a s. Prism' (Step a s) Unit 26 | _Done = prism (const Done) case _ of 27 | Done -> Right unit 28 | other -> Left other 29 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Maybe/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Maybe.Trans.Lens where 2 | 3 | import Control.Monad.Maybe.Trans (MaybeT) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Maybe (Maybe) 7 | 8 | _MaybeT :: forall m a. Lens' (MaybeT m a) (m (Maybe a)) 9 | _MaybeT = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Control/Monad/RWS/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.RWS.Lens where 2 | 3 | import Control.Monad.RWS (RWS) 4 | import Control.Monad.RWS.Trans (RWST) 5 | import Data.Identity (Identity) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _RWS :: forall r w s. Iso' (RWS r w s) (RWST r w s Identity) 10 | _RWS = identity 11 | -------------------------------------------------------------------------------- /lenses/Control/Monad/RWS/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.RWS.Trans.Lens where 2 | 3 | import Control.Monad.RWS.Trans (RWST, RWSResult(..)) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso (iso) 6 | import Data.Lens.Iso.Newtype (_Newtype) 7 | 8 | _RWSResult 9 | :: forall state result writer 10 | . Lens' (RWSResult state result writer) { arg1 :: state, arg2 :: result, arg3 :: writer } 11 | _RWSResult = iso (\(RWSResult arg1 arg2 arg3) -> { arg1: arg1, arg2: arg2, arg3: arg3 }) 12 | \{ arg1, arg2, arg3 } -> RWSResult arg1 arg2 arg3 13 | 14 | _RWST :: forall r w s m a. Lens' (RWST r w s m a) (r -> s -> m (RWSResult s a w)) 15 | _RWST = _Newtype 16 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Reader/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Reader.Lens where 2 | 3 | import Control.Monad.Reader (Reader) 4 | import Control.Monad.Reader.Trans (ReaderT) 5 | import Data.Identity (Identity) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _Reader :: forall r. Iso' (Reader r) (ReaderT r Identity) 10 | _Reader = identity 11 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Reader/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Reader.Trans.Lens where 2 | 3 | import Control.Monad.Reader.Trans (ReaderT) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _ReaderT :: forall r m a. Lens' (ReaderT r m a) (r -> m a) 8 | _ReaderT = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Rec/Class/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Rec.Class.Lens where 2 | 3 | import Control.Monad.Rec.Class (Step(..)) 4 | import Data.Either (Either(..)) 5 | import Data.Lens.Prism (Prism', prism) 6 | 7 | _Loop :: forall a b. Prism' (Step a b) a 8 | _Loop = prism Loop case _ of 9 | Loop a -> Right a 10 | other -> Left other 11 | 12 | _Done :: forall a b. Prism' (Step a b) b 13 | _Done = prism Done case _ of 14 | Done a -> Right a 15 | other -> Left other 16 | -------------------------------------------------------------------------------- /lenses/Control/Monad/State/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.State.Lens where 2 | 3 | import Control.Monad.State (State) 4 | import Control.Monad.State.Trans (StateT) 5 | import Data.Identity (Identity) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _State :: forall s. Iso' (State s) (StateT s Identity) 10 | _State = identity 11 | -------------------------------------------------------------------------------- /lenses/Control/Monad/State/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.State.Trans.Lens where 2 | 3 | import Control.Monad.State.Trans (StateT) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Tuple (Tuple) 7 | 8 | _StateT :: forall s m a. Lens' (StateT s m a) (s -> m (Tuple a s)) 9 | _StateT = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Trampoline/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Trampoline.Lens where 2 | 3 | import Prelude 4 | 5 | import Control.Monad.Free (Free) 6 | import Control.Monad.Trampoline (Trampoline) 7 | import Data.Lens.Iso (Iso') 8 | import Prelude (identity) 9 | 10 | _Trampoline :: Iso' Trampoline (Free ((->) Unit)) 11 | _Trampoline = identity 12 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Writer/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Writer.Lens where 2 | 3 | import Control.Monad.Writer (Writer) 4 | import Control.Monad.Writer.Trans (WriterT) 5 | import Data.Identity (Identity) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _Writer :: forall w. Iso' (Writer w) (WriterT w Identity) 10 | _Writer = identity 11 | -------------------------------------------------------------------------------- /lenses/Control/Monad/Writer/Trans/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Monad.Writer.Trans.Lens where 2 | 3 | import Control.Monad.Writer.Trans (WriterT) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Tuple (Tuple) 7 | 8 | _WriterT :: forall w m a. Lens' (WriterT w m a) (m (Tuple a w)) 9 | _WriterT = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Control/Parallel/Class/Lens.purs: -------------------------------------------------------------------------------- 1 | module Control.Parallel.Class.Lens where 2 | 3 | import Prelude 4 | 5 | import Control.Monad.Cont.Trans (ContT) 6 | import Control.Parallel.Class (ParCont) 7 | import Data.Lens (Lens') 8 | import Data.Lens.Iso.Newtype (_Newtype) 9 | 10 | _ParCont :: forall m a. Lens' (ParCont m a) (ContT Unit m a) 11 | _ParCont = _Newtype 12 | -------------------------------------------------------------------------------- /lenses/Data/Array/ST/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Array.ST.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Array.ST (Assoc) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _Assoc :: forall a. Iso' (Assoc a) { value :: a, index :: Int } 10 | _Assoc = identity 11 | -------------------------------------------------------------------------------- /lenses/Data/ArrayBuffer/Types/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.ArrayBuffer.Types.Lens where 2 | 3 | import Data.ArrayBuffer.Types (ArrayView, ByteLength, ByteOffset, Float32, Float32Array, Float64, Float64Array, Int16, Int16Array, Int32, Int32Array, Int8, Int8Array, Uint16, Uint16Array, Uint32, Uint32Array, Uint8, Uint8Array, Uint8Clamped, Uint8ClampedArray) 4 | import Data.Lens.Iso (Iso') 5 | import Prelude (identity) 6 | 7 | _ByteOffset :: Iso' ByteOffset Int 8 | _ByteOffset = identity 9 | 10 | _ByteLength :: Iso' ByteLength Int 11 | _ByteLength = identity 12 | 13 | _Int8Array :: Iso' Int8Array (ArrayView Int8) 14 | _Int8Array = identity 15 | 16 | _Int16Array :: Iso' Int16Array (ArrayView Int16) 17 | _Int16Array = identity 18 | 19 | _Int32Array :: Iso' Int32Array (ArrayView Int32) 20 | _Int32Array = identity 21 | 22 | _Uint8Array :: Iso' Uint8Array (ArrayView Uint8) 23 | _Uint8Array = identity 24 | 25 | _Uint16Array :: Iso' Uint16Array (ArrayView Uint16) 26 | _Uint16Array = identity 27 | 28 | _Uint32Array :: Iso' Uint32Array (ArrayView Uint32) 29 | _Uint32Array = identity 30 | 31 | _Uint8ClampedArray :: Iso' Uint8ClampedArray (ArrayView Uint8Clamped) 32 | _Uint8ClampedArray = identity 33 | 34 | _Float32Array :: Iso' Float32Array (ArrayView Float32) 35 | _Float32Array = identity 36 | 37 | _Float64Array :: Iso' Float64Array (ArrayView Float64) 38 | _Float64Array = identity 39 | -------------------------------------------------------------------------------- /lenses/Data/Bifunctor/Join/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Bifunctor.Join.Lens where 2 | 3 | import Data.Bifunctor.Join (Join) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Join :: forall p a. Lens' (Join p a) (p a a) 8 | _Join = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/CatList/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.CatList.Lens where 2 | 3 | import Data.CatList (CatList(..)) 4 | import Data.CatQueue as Q 5 | import Data.Either (Either(..)) 6 | import Data.Lens.Prism (Prism', prism) 7 | import Data.Tuple (Tuple(..)) 8 | import Prelude (Unit, const, unit) 9 | 10 | _CatNil :: forall a. Prism' (CatList a) Unit 11 | _CatNil = prism (const CatNil) case _ of 12 | CatNil -> Right unit 13 | other -> Left other 14 | 15 | _CatCons :: forall a. Prism' (CatList a) (Tuple a (Q.CatQueue (CatList a))) 16 | _CatCons = prism (\(Tuple a b) -> CatCons a b) case _ of 17 | CatCons a b -> Right (Tuple a b) 18 | other -> Left other 19 | -------------------------------------------------------------------------------- /lenses/Data/CatQueue/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.CatQueue.Lens where 2 | 3 | import Data.CatQueue (CatQueue(..)) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso (iso) 6 | import Data.List (List) 7 | import Data.Tuple (Tuple(..)) 8 | 9 | _CatQueue :: forall a. Lens' (CatQueue a) (Tuple (List a) (List a)) 10 | _CatQueue = iso (\(CatQueue a b) -> Tuple a b) \(Tuple a b) -> CatQueue a b 11 | -------------------------------------------------------------------------------- /lenses/Data/CodePoint/Unicode/Internal/Casing/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.CodePoint.Unicode.Internal.Casing.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.CodePoint.Unicode.Internal.Casing (CaseRec) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | 9 | _CaseRec :: Iso' CaseRec 10 | { code :: Int 11 | , lower :: Array Int 12 | , title :: Array Int 13 | , upper :: Array Int 14 | , fold :: Int 15 | , foldFull :: Array Int 16 | } 17 | _CaseRec = identity 18 | -------------------------------------------------------------------------------- /lenses/Data/CodePoint/Unicode/Internal/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.CodePoint.Unicode.Internal.Lens where 2 | 3 | import Data.CodePoint.Unicode.Internal (UnicodeCategory(..)) 4 | import Data.Either (Either(..)) 5 | import Data.Lens.Prism (Prism', prism) 6 | import Prelude (Unit, const, unit) 7 | 8 | _NUMCAT_LU :: Prism' UnicodeCategory Unit 9 | _NUMCAT_LU = prism (const NUMCAT_LU) case _ of 10 | NUMCAT_LU -> Right unit 11 | other -> Left other 12 | 13 | _NUMCAT_LL :: Prism' UnicodeCategory Unit 14 | _NUMCAT_LL = prism (const NUMCAT_LL) case _ of 15 | NUMCAT_LL -> Right unit 16 | other -> Left other 17 | 18 | _NUMCAT_LT :: Prism' UnicodeCategory Unit 19 | _NUMCAT_LT = prism (const NUMCAT_LT) case _ of 20 | NUMCAT_LT -> Right unit 21 | other -> Left other 22 | 23 | _NUMCAT_LM :: Prism' UnicodeCategory Unit 24 | _NUMCAT_LM = prism (const NUMCAT_LM) case _ of 25 | NUMCAT_LM -> Right unit 26 | other -> Left other 27 | 28 | _NUMCAT_LO :: Prism' UnicodeCategory Unit 29 | _NUMCAT_LO = prism (const NUMCAT_LO) case _ of 30 | NUMCAT_LO -> Right unit 31 | other -> Left other 32 | 33 | _NUMCAT_MN :: Prism' UnicodeCategory Unit 34 | _NUMCAT_MN = prism (const NUMCAT_MN) case _ of 35 | NUMCAT_MN -> Right unit 36 | other -> Left other 37 | 38 | _NUMCAT_MC :: Prism' UnicodeCategory Unit 39 | _NUMCAT_MC = prism (const NUMCAT_MC) case _ of 40 | NUMCAT_MC -> Right unit 41 | other -> Left other 42 | 43 | _NUMCAT_ME :: Prism' UnicodeCategory Unit 44 | _NUMCAT_ME = prism (const NUMCAT_ME) case _ of 45 | NUMCAT_ME -> Right unit 46 | other -> Left other 47 | 48 | _NUMCAT_ND :: Prism' UnicodeCategory Unit 49 | _NUMCAT_ND = prism (const NUMCAT_ND) case _ of 50 | NUMCAT_ND -> Right unit 51 | other -> Left other 52 | 53 | _NUMCAT_NL :: Prism' UnicodeCategory Unit 54 | _NUMCAT_NL = prism (const NUMCAT_NL) case _ of 55 | NUMCAT_NL -> Right unit 56 | other -> Left other 57 | 58 | _NUMCAT_NO :: Prism' UnicodeCategory Unit 59 | _NUMCAT_NO = prism (const NUMCAT_NO) case _ of 60 | NUMCAT_NO -> Right unit 61 | other -> Left other 62 | 63 | _NUMCAT_PC :: Prism' UnicodeCategory Unit 64 | _NUMCAT_PC = prism (const NUMCAT_PC) case _ of 65 | NUMCAT_PC -> Right unit 66 | other -> Left other 67 | 68 | _NUMCAT_PD :: Prism' UnicodeCategory Unit 69 | _NUMCAT_PD = prism (const NUMCAT_PD) case _ of 70 | NUMCAT_PD -> Right unit 71 | other -> Left other 72 | 73 | _NUMCAT_PS :: Prism' UnicodeCategory Unit 74 | _NUMCAT_PS = prism (const NUMCAT_PS) case _ of 75 | NUMCAT_PS -> Right unit 76 | other -> Left other 77 | 78 | _NUMCAT_PE :: Prism' UnicodeCategory Unit 79 | _NUMCAT_PE = prism (const NUMCAT_PE) case _ of 80 | NUMCAT_PE -> Right unit 81 | other -> Left other 82 | 83 | _NUMCAT_PI :: Prism' UnicodeCategory Unit 84 | _NUMCAT_PI = prism (const NUMCAT_PI) case _ of 85 | NUMCAT_PI -> Right unit 86 | other -> Left other 87 | 88 | _NUMCAT_PF :: Prism' UnicodeCategory Unit 89 | _NUMCAT_PF = prism (const NUMCAT_PF) case _ of 90 | NUMCAT_PF -> Right unit 91 | other -> Left other 92 | 93 | _NUMCAT_PO :: Prism' UnicodeCategory Unit 94 | _NUMCAT_PO = prism (const NUMCAT_PO) case _ of 95 | NUMCAT_PO -> Right unit 96 | other -> Left other 97 | 98 | _NUMCAT_SM :: Prism' UnicodeCategory Unit 99 | _NUMCAT_SM = prism (const NUMCAT_SM) case _ of 100 | NUMCAT_SM -> Right unit 101 | other -> Left other 102 | 103 | _NUMCAT_SC :: Prism' UnicodeCategory Unit 104 | _NUMCAT_SC = prism (const NUMCAT_SC) case _ of 105 | NUMCAT_SC -> Right unit 106 | other -> Left other 107 | 108 | _NUMCAT_SK :: Prism' UnicodeCategory Unit 109 | _NUMCAT_SK = prism (const NUMCAT_SK) case _ of 110 | NUMCAT_SK -> Right unit 111 | other -> Left other 112 | 113 | _NUMCAT_SO :: Prism' UnicodeCategory Unit 114 | _NUMCAT_SO = prism (const NUMCAT_SO) case _ of 115 | NUMCAT_SO -> Right unit 116 | other -> Left other 117 | 118 | _NUMCAT_ZS :: Prism' UnicodeCategory Unit 119 | _NUMCAT_ZS = prism (const NUMCAT_ZS) case _ of 120 | NUMCAT_ZS -> Right unit 121 | other -> Left other 122 | 123 | _NUMCAT_ZL :: Prism' UnicodeCategory Unit 124 | _NUMCAT_ZL = prism (const NUMCAT_ZL) case _ of 125 | NUMCAT_ZL -> Right unit 126 | other -> Left other 127 | 128 | _NUMCAT_ZP :: Prism' UnicodeCategory Unit 129 | _NUMCAT_ZP = prism (const NUMCAT_ZP) case _ of 130 | NUMCAT_ZP -> Right unit 131 | other -> Left other 132 | 133 | _NUMCAT_CC :: Prism' UnicodeCategory Unit 134 | _NUMCAT_CC = prism (const NUMCAT_CC) case _ of 135 | NUMCAT_CC -> Right unit 136 | other -> Left other 137 | 138 | _NUMCAT_CF :: Prism' UnicodeCategory Unit 139 | _NUMCAT_CF = prism (const NUMCAT_CF) case _ of 140 | NUMCAT_CF -> Right unit 141 | other -> Left other 142 | 143 | _NUMCAT_CS :: Prism' UnicodeCategory Unit 144 | _NUMCAT_CS = prism (const NUMCAT_CS) case _ of 145 | NUMCAT_CS -> Right unit 146 | other -> Left other 147 | 148 | _NUMCAT_CO :: Prism' UnicodeCategory Unit 149 | _NUMCAT_CO = prism (const NUMCAT_CO) case _ of 150 | NUMCAT_CO -> Right unit 151 | other -> Left other 152 | 153 | _NUMCAT_CN :: Prism' UnicodeCategory Unit 154 | _NUMCAT_CN = prism (const NUMCAT_CN) case _ of 155 | NUMCAT_CN -> Right unit 156 | other -> Left other 157 | -------------------------------------------------------------------------------- /lenses/Data/CodePoint/Unicode/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.CodePoint.Unicode.Lens where 2 | 3 | import Data.CodePoint.Unicode (GeneralCategory(..)) 4 | import Data.Either (Either(..)) 5 | import Data.Lens.Prism (Prism', prism) 6 | import Prelude (Unit, const, unit) 7 | 8 | _UppercaseLetter :: Prism' GeneralCategory Unit 9 | _UppercaseLetter = prism (const UppercaseLetter) case _ of 10 | UppercaseLetter -> Right unit 11 | other -> Left other 12 | 13 | _LowercaseLetter :: Prism' GeneralCategory Unit 14 | _LowercaseLetter = prism (const LowercaseLetter) case _ of 15 | LowercaseLetter -> Right unit 16 | other -> Left other 17 | 18 | _TitlecaseLetter :: Prism' GeneralCategory Unit 19 | _TitlecaseLetter = prism (const TitlecaseLetter) case _ of 20 | TitlecaseLetter -> Right unit 21 | other -> Left other 22 | 23 | _ModifierLetter :: Prism' GeneralCategory Unit 24 | _ModifierLetter = prism (const ModifierLetter) case _ of 25 | ModifierLetter -> Right unit 26 | other -> Left other 27 | 28 | _OtherLetter :: Prism' GeneralCategory Unit 29 | _OtherLetter = prism (const OtherLetter) case _ of 30 | OtherLetter -> Right unit 31 | other -> Left other 32 | 33 | _NonSpacingMark :: Prism' GeneralCategory Unit 34 | _NonSpacingMark = prism (const NonSpacingMark) case _ of 35 | NonSpacingMark -> Right unit 36 | other -> Left other 37 | 38 | _SpacingCombiningMark :: Prism' GeneralCategory Unit 39 | _SpacingCombiningMark = prism (const SpacingCombiningMark) case _ of 40 | SpacingCombiningMark -> Right unit 41 | other -> Left other 42 | 43 | _EnclosingMark :: Prism' GeneralCategory Unit 44 | _EnclosingMark = prism (const EnclosingMark) case _ of 45 | EnclosingMark -> Right unit 46 | other -> Left other 47 | 48 | _DecimalNumber :: Prism' GeneralCategory Unit 49 | _DecimalNumber = prism (const DecimalNumber) case _ of 50 | DecimalNumber -> Right unit 51 | other -> Left other 52 | 53 | _LetterNumber :: Prism' GeneralCategory Unit 54 | _LetterNumber = prism (const LetterNumber) case _ of 55 | LetterNumber -> Right unit 56 | other -> Left other 57 | 58 | _OtherNumber :: Prism' GeneralCategory Unit 59 | _OtherNumber = prism (const OtherNumber) case _ of 60 | OtherNumber -> Right unit 61 | other -> Left other 62 | 63 | _ConnectorPunctuation :: Prism' GeneralCategory Unit 64 | _ConnectorPunctuation = prism (const ConnectorPunctuation) case _ of 65 | ConnectorPunctuation -> Right unit 66 | other -> Left other 67 | 68 | _DashPunctuation :: Prism' GeneralCategory Unit 69 | _DashPunctuation = prism (const DashPunctuation) case _ of 70 | DashPunctuation -> Right unit 71 | other -> Left other 72 | 73 | _OpenPunctuation :: Prism' GeneralCategory Unit 74 | _OpenPunctuation = prism (const OpenPunctuation) case _ of 75 | OpenPunctuation -> Right unit 76 | other -> Left other 77 | 78 | _ClosePunctuation :: Prism' GeneralCategory Unit 79 | _ClosePunctuation = prism (const ClosePunctuation) case _ of 80 | ClosePunctuation -> Right unit 81 | other -> Left other 82 | 83 | _InitialQuote :: Prism' GeneralCategory Unit 84 | _InitialQuote = prism (const InitialQuote) case _ of 85 | InitialQuote -> Right unit 86 | other -> Left other 87 | 88 | _FinalQuote :: Prism' GeneralCategory Unit 89 | _FinalQuote = prism (const FinalQuote) case _ of 90 | FinalQuote -> Right unit 91 | other -> Left other 92 | 93 | _OtherPunctuation :: Prism' GeneralCategory Unit 94 | _OtherPunctuation = prism (const OtherPunctuation) case _ of 95 | OtherPunctuation -> Right unit 96 | other -> Left other 97 | 98 | _MathSymbol :: Prism' GeneralCategory Unit 99 | _MathSymbol = prism (const MathSymbol) case _ of 100 | MathSymbol -> Right unit 101 | other -> Left other 102 | 103 | _CurrencySymbol :: Prism' GeneralCategory Unit 104 | _CurrencySymbol = prism (const CurrencySymbol) case _ of 105 | CurrencySymbol -> Right unit 106 | other -> Left other 107 | 108 | _ModifierSymbol :: Prism' GeneralCategory Unit 109 | _ModifierSymbol = prism (const ModifierSymbol) case _ of 110 | ModifierSymbol -> Right unit 111 | other -> Left other 112 | 113 | _OtherSymbol :: Prism' GeneralCategory Unit 114 | _OtherSymbol = prism (const OtherSymbol) case _ of 115 | OtherSymbol -> Right unit 116 | other -> Left other 117 | 118 | _Space :: Prism' GeneralCategory Unit 119 | _Space = prism (const Space) case _ of 120 | Space -> Right unit 121 | other -> Left other 122 | 123 | _LineSeparator :: Prism' GeneralCategory Unit 124 | _LineSeparator = prism (const LineSeparator) case _ of 125 | LineSeparator -> Right unit 126 | other -> Left other 127 | 128 | _ParagraphSeparator :: Prism' GeneralCategory Unit 129 | _ParagraphSeparator = prism (const ParagraphSeparator) case _ of 130 | ParagraphSeparator -> Right unit 131 | other -> Left other 132 | 133 | _Control :: Prism' GeneralCategory Unit 134 | _Control = prism (const Control) case _ of 135 | Control -> Right unit 136 | other -> Left other 137 | 138 | _Format :: Prism' GeneralCategory Unit 139 | _Format = prism (const Format) case _ of 140 | Format -> Right unit 141 | other -> Left other 142 | 143 | _Surrogate :: Prism' GeneralCategory Unit 144 | _Surrogate = prism (const Surrogate) case _ of 145 | Surrogate -> Right unit 146 | other -> Left other 147 | 148 | _PrivateUse :: Prism' GeneralCategory Unit 149 | _PrivateUse = prism (const PrivateUse) case _ of 150 | PrivateUse -> Right unit 151 | other -> Left other 152 | 153 | _NotAssigned :: Prism' GeneralCategory Unit 154 | _NotAssigned = prism (const NotAssigned) case _ of 155 | NotAssigned -> Right unit 156 | other -> Left other 157 | -------------------------------------------------------------------------------- /lenses/Data/Comparison/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Comparison.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Comparison (Comparison) 6 | import Data.Lens (Lens') 7 | import Data.Lens.Iso.Newtype (_Newtype) 8 | 9 | _Comparison :: forall a. Lens' (Comparison a) (a -> a -> Ordering) 10 | _Comparison = _Newtype 11 | -------------------------------------------------------------------------------- /lenses/Data/Const/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Const.Lens where 2 | 3 | import Data.Const (Const) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Const :: forall a b. Lens' (Const a b) a 8 | _Const = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Date/Component/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Date.Component.Lens where 2 | 3 | import Data.Date.Component (Month(..), Weekday(..)) 4 | import Data.Either (Either(..)) 5 | import Data.Lens.Prism (Prism', prism) 6 | import Prelude (Unit, const, unit) 7 | 8 | _January :: Prism' Month Unit 9 | _January = prism (const January) case _ of 10 | January -> Right unit 11 | other -> Left other 12 | 13 | _February :: Prism' Month Unit 14 | _February = prism (const February) case _ of 15 | February -> Right unit 16 | other -> Left other 17 | 18 | _March :: Prism' Month Unit 19 | _March = prism (const March) case _ of 20 | March -> Right unit 21 | other -> Left other 22 | 23 | _April :: Prism' Month Unit 24 | _April = prism (const April) case _ of 25 | April -> Right unit 26 | other -> Left other 27 | 28 | _May :: Prism' Month Unit 29 | _May = prism (const May) case _ of 30 | May -> Right unit 31 | other -> Left other 32 | 33 | _June :: Prism' Month Unit 34 | _June = prism (const June) case _ of 35 | June -> Right unit 36 | other -> Left other 37 | 38 | _July :: Prism' Month Unit 39 | _July = prism (const July) case _ of 40 | July -> Right unit 41 | other -> Left other 42 | 43 | _August :: Prism' Month Unit 44 | _August = prism (const August) case _ of 45 | August -> Right unit 46 | other -> Left other 47 | 48 | _September :: Prism' Month Unit 49 | _September = prism (const September) case _ of 50 | September -> Right unit 51 | other -> Left other 52 | 53 | _October :: Prism' Month Unit 54 | _October = prism (const October) case _ of 55 | October -> Right unit 56 | other -> Left other 57 | 58 | _November :: Prism' Month Unit 59 | _November = prism (const November) case _ of 60 | November -> Right unit 61 | other -> Left other 62 | 63 | _December :: Prism' Month Unit 64 | _December = prism (const December) case _ of 65 | December -> Right unit 66 | other -> Left other 67 | 68 | _Monday :: Prism' Weekday Unit 69 | _Monday = prism (const Monday) case _ of 70 | Monday -> Right unit 71 | other -> Left other 72 | 73 | _Tuesday :: Prism' Weekday Unit 74 | _Tuesday = prism (const Tuesday) case _ of 75 | Tuesday -> Right unit 76 | other -> Left other 77 | 78 | _Wednesday :: Prism' Weekday Unit 79 | _Wednesday = prism (const Wednesday) case _ of 80 | Wednesday -> Right unit 81 | other -> Left other 82 | 83 | _Thursday :: Prism' Weekday Unit 84 | _Thursday = prism (const Thursday) case _ of 85 | Thursday -> Right unit 86 | other -> Left other 87 | 88 | _Friday :: Prism' Weekday Unit 89 | _Friday = prism (const Friday) case _ of 90 | Friday -> Right unit 91 | other -> Left other 92 | 93 | _Saturday :: Prism' Weekday Unit 94 | _Saturday = prism (const Saturday) case _ of 95 | Saturday -> Right unit 96 | other -> Left other 97 | 98 | _Sunday :: Prism' Weekday Unit 99 | _Sunday = prism (const Sunday) case _ of 100 | Sunday -> Right unit 101 | other -> Left other 102 | -------------------------------------------------------------------------------- /lenses/Data/DateTime/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.DateTime.Lens where 2 | 3 | import Data.Date (Date) 4 | import Data.DateTime (DateTime(..)) 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso (iso) 7 | import Data.Time (Time) 8 | import Data.Tuple (Tuple(..)) 9 | 10 | _DateTime :: Lens' DateTime (Tuple Date Time) 11 | _DateTime = iso (\(DateTime a b) -> Tuple a b) \(Tuple a b) -> DateTime a b 12 | -------------------------------------------------------------------------------- /lenses/Data/Either/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Either.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Prism (Prism', prism) 5 | 6 | _Left :: forall a b. Prism' (Either a b) a 7 | _Left = prism Left case _ of 8 | Left a -> Right a 9 | other -> Left other 10 | 11 | _Right :: forall a b. Prism' (Either a b) b 12 | _Right = prism Right case _ of 13 | Right a -> Right a 14 | other -> Left other 15 | -------------------------------------------------------------------------------- /lenses/Data/Either/Nested/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Either.Nested.Lens where 2 | 3 | import Data.Either.Nested (Either1, Either10, Either2, Either3, Either4, Either5, Either6, Either7, Either8, Either9, type (\/)) 4 | import Data.Lens.Iso (Iso') 5 | import Data.Void (Void) 6 | import Prelude (identity) 7 | 8 | _Either1 :: forall a. Iso' (Either1 a) (a \/ Void) 9 | _Either1 = identity 10 | 11 | _Either2 :: forall a b. Iso' (Either2 a b) (a \/ b \/ Void) 12 | _Either2 = identity 13 | 14 | _Either3 :: forall a b c. Iso' (Either3 a b c) (a \/ b \/ c \/ Void) 15 | _Either3 = identity 16 | 17 | _Either4 :: forall a b c d. Iso' (Either4 a b c d) (a \/ b \/ c \/ d \/ Void) 18 | _Either4 = identity 19 | 20 | _Either5 :: forall a b c d e. Iso' (Either5 a b c d e) (a \/ b \/ c \/ d \/ e \/ Void) 21 | _Either5 = identity 22 | 23 | _Either6 :: forall a b c d e f. Iso' (Either6 a b c d e f) (a \/ b \/ c \/ d \/ e \/ f \/ Void) 24 | _Either6 = identity 25 | 26 | _Either7 27 | :: forall a b c d e f g. Iso' (Either7 a b c d e f g) (a \/ b \/ c \/ d \/ e \/ f \/ g \/ Void) 28 | _Either7 = identity 29 | 30 | _Either8 31 | :: forall a b c d e f g h 32 | . Iso' (Either8 a b c d e f g h) (a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ Void) 33 | _Either8 = identity 34 | 35 | _Either9 36 | :: forall a b c d e f g h i 37 | . Iso' (Either9 a b c d e f g h i) (a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ i \/ Void) 38 | _Either9 = identity 39 | 40 | _Either10 41 | :: forall a b c d e f g h i j 42 | . Iso' (Either10 a b c d e f g h i j) (a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ i \/ j \/ Void) 43 | _Either10 = identity 44 | -------------------------------------------------------------------------------- /lenses/Data/Enum/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Enum.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Enum (Cardinality) 6 | import Data.Lens (Lens') 7 | import Data.Lens.Iso.Newtype (_Newtype) 8 | 9 | _Cardinality :: forall a. Lens' (Cardinality a) Int 10 | _Cardinality = _Newtype 11 | -------------------------------------------------------------------------------- /lenses/Data/Equivalence/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Equivalence.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Equivalence (Equivalence) 6 | import Data.Lens (Lens') 7 | import Data.Lens.Iso.Newtype (_Newtype) 8 | 9 | _Equivalence :: forall a. Lens' (Equivalence a) (a -> a -> Boolean) 10 | _Equivalence = _Newtype 11 | -------------------------------------------------------------------------------- /lenses/Data/Function/Uncurried/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Function.Uncurried.Lens where 2 | 3 | import Data.Function.Uncurried (Fn1) 4 | import Data.Lens.Iso (Iso') 5 | import Prelude (identity) 6 | 7 | _Fn1 :: forall a b. Iso' (Fn1 a b) (a -> b) 8 | _Fn1 = identity 9 | -------------------------------------------------------------------------------- /lenses/Data/Functor/App/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.App.Lens where 2 | 3 | import Data.Functor.App (App) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _App :: forall f a. Lens' (App f a) (f a) 8 | _App = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Functor/Clown/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.Clown.Lens where 2 | 3 | import Data.Functor.Clown (Clown) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Clown :: forall f a b. Lens' (Clown f a b) (f a) 8 | _Clown = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Functor/Compose/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.Compose.Lens where 2 | 3 | import Data.Functor.Compose (Compose) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Compose :: forall f g a. Lens' (Compose f g a) (f (g a)) 8 | _Compose = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Functor/Coproduct/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.Coproduct.Lens where 2 | 3 | import Data.Either (Either) 4 | import Data.Functor.Coproduct (Coproduct) 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso.Newtype (_Newtype) 7 | 8 | _Coproduct :: forall f g a. Lens' (Coproduct f g a) (Either (f a) (g a)) 9 | _Coproduct = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/Functor/Coproduct/Nested/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.Coproduct.Nested.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Const (Const) 6 | import Data.Functor.Coproduct (Coproduct) 7 | import Data.Functor.Coproduct.Nested (C10, C11, C2, C3, C4, C5, C6, C7, C8, C9, Coproduct1, Coproduct10, Coproduct2, Coproduct3, Coproduct4, Coproduct5, Coproduct6, Coproduct7, Coproduct8, Coproduct9) 8 | import Data.Lens.Iso (Iso') 9 | import Prelude (identity) 10 | 11 | _Coproduct1 :: forall a. Iso' (Coproduct1 a) (C2 a (Const Void)) 12 | _Coproduct1 = identity 13 | 14 | _Coproduct2 :: forall a b. Iso' (Coproduct2 a b) (C3 a b (Const Void)) 15 | _Coproduct2 = identity 16 | 17 | _Coproduct3 :: forall a b c. Iso' (Coproduct3 a b c) (C4 a b c (Const Void)) 18 | _Coproduct3 = identity 19 | 20 | _Coproduct4 :: forall a b c d. Iso' (Coproduct4 a b c d) (C5 a b c d (Const Void)) 21 | _Coproduct4 = identity 22 | 23 | _Coproduct5 :: forall a b c d e. Iso' (Coproduct5 a b c d e) (C6 a b c d e (Const Void)) 24 | _Coproduct5 = identity 25 | 26 | _Coproduct6 :: forall a b c d e f. Iso' (Coproduct6 a b c d e f) (C7 a b c d e f (Const Void)) 27 | _Coproduct6 = identity 28 | 29 | _Coproduct7 30 | :: forall a b c d e f g. Iso' (Coproduct7 a b c d e f g) (C8 a b c d e f g (Const Void)) 31 | _Coproduct7 = identity 32 | 33 | _Coproduct8 34 | :: forall a b c d e f g h. Iso' (Coproduct8 a b c d e f g h) (C9 a b c d e f g h (Const Void)) 35 | _Coproduct8 = identity 36 | 37 | _Coproduct9 38 | :: forall a b c d e f g h i 39 | . Iso' (Coproduct9 a b c d e f g h i) (C10 a b c d e f g h i (Const Void)) 40 | _Coproduct9 = identity 41 | 42 | _Coproduct10 43 | :: forall a b c d e f g h i j 44 | . Iso' (Coproduct10 a b c d e f g h i j) (C11 a b c d e f g h i j (Const Void)) 45 | _Coproduct10 = identity 46 | 47 | _C2 :: forall a z. Iso' (C2 a z) (Coproduct a z) 48 | _C2 = identity 49 | 50 | _C3 :: forall a b z. Iso' (C3 a b z) (Coproduct a (C2 b z)) 51 | _C3 = identity 52 | 53 | _C4 :: forall a b c z. Iso' (C4 a b c z) (Coproduct a (C3 b c z)) 54 | _C4 = identity 55 | 56 | _C5 :: forall a b c d z. Iso' (C5 a b c d z) (Coproduct a (C4 b c d z)) 57 | _C5 = identity 58 | 59 | _C6 :: forall a b c d e z. Iso' (C6 a b c d e z) (Coproduct a (C5 b c d e z)) 60 | _C6 = identity 61 | 62 | _C7 :: forall a b c d e f z. Iso' (C7 a b c d e f z) (Coproduct a (C6 b c d e f z)) 63 | _C7 = identity 64 | 65 | _C8 :: forall a b c d e f g z. Iso' (C8 a b c d e f g z) (Coproduct a (C7 b c d e f g z)) 66 | _C8 = identity 67 | 68 | _C9 :: forall a b c d e f g h z. Iso' (C9 a b c d e f g h z) (Coproduct a (C8 b c d e f g h z)) 69 | _C9 = identity 70 | 71 | _C10 72 | :: forall a b c d e f g h i z. Iso' (C10 a b c d e f g h i z) (Coproduct a (C9 b c d e f g h i z)) 73 | _C10 = identity 74 | 75 | _C11 76 | :: forall a b c d e f g h i j z 77 | . Iso' (C11 a b c d e f g h i j z) (Coproduct a (C10 b c d e f g h i j z)) 78 | _C11 = identity 79 | -------------------------------------------------------------------------------- /lenses/Data/Functor/Costar/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.Costar.Lens where 2 | 3 | import Data.Functor.Costar (Costar) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Costar :: forall f b a. Lens' (Costar f b a) (f b -> a) 8 | _Costar = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Functor/Flip/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.Flip.Lens where 2 | 3 | import Data.Functor.Flip (Flip) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Flip :: forall p a b. Lens' (Flip p a b) (p b a) 8 | _Flip = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Functor/Joker/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.Joker.Lens where 2 | 3 | import Data.Functor.Joker (Joker) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Joker :: forall g a b. Lens' (Joker g a b) (g b) 8 | _Joker = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Functor/Product/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.Product.Lens where 2 | 3 | import Data.Functor.Product (Product) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Tuple (Tuple) 7 | 8 | _Product :: forall f g a. Lens' (Product f g a) (Tuple (f a) (g a)) 9 | _Product = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/Functor/Product/Nested/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.Product.Nested.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Const (Const) 6 | import Data.Functor.Product (Product) 7 | import Data.Functor.Product.Nested (Product1, Product10, Product2, Product3, Product4, Product5, Product6, Product7, Product8, Product9, T10, T11, T2, T3, T4, T5, T6, T7, T8, T9) 8 | import Data.Lens.Iso (Iso') 9 | import Prelude (identity) 10 | 11 | _Product1 :: forall a. Iso' (Product1 a) (T2 a (Const Unit)) 12 | _Product1 = identity 13 | 14 | _Product2 :: forall a b. Iso' (Product2 a b) (T3 a b (Const Unit)) 15 | _Product2 = identity 16 | 17 | _Product3 :: forall a b c. Iso' (Product3 a b c) (T4 a b c (Const Unit)) 18 | _Product3 = identity 19 | 20 | _Product4 :: forall a b c d. Iso' (Product4 a b c d) (T5 a b c d (Const Unit)) 21 | _Product4 = identity 22 | 23 | _Product5 :: forall a b c d e. Iso' (Product5 a b c d e) (T6 a b c d e (Const Unit)) 24 | _Product5 = identity 25 | 26 | _Product6 :: forall a b c d e f. Iso' (Product6 a b c d e f) (T7 a b c d e f (Const Unit)) 27 | _Product6 = identity 28 | 29 | _Product7 :: forall a b c d e f g. Iso' (Product7 a b c d e f g) (T8 a b c d e f g (Const Unit)) 30 | _Product7 = identity 31 | 32 | _Product8 33 | :: forall a b c d e f g h. Iso' (Product8 a b c d e f g h) (T9 a b c d e f g h (Const Unit)) 34 | _Product8 = identity 35 | 36 | _Product9 37 | :: forall a b c d e f g h i 38 | . Iso' (Product9 a b c d e f g h i) (T10 a b c d e f g h i (Const Unit)) 39 | _Product9 = identity 40 | 41 | _Product10 42 | :: forall a b c d e f g h i j 43 | . Iso' (Product10 a b c d e f g h i j) (T11 a b c d e f g h i j (Const Unit)) 44 | _Product10 = identity 45 | 46 | _T2 :: forall a z. Iso' (T2 a z) (Product a z) 47 | _T2 = identity 48 | 49 | _T3 :: forall a b z. Iso' (T3 a b z) (Product a (T2 b z)) 50 | _T3 = identity 51 | 52 | _T4 :: forall a b c z. Iso' (T4 a b c z) (Product a (T3 b c z)) 53 | _T4 = identity 54 | 55 | _T5 :: forall a b c d z. Iso' (T5 a b c d z) (Product a (T4 b c d z)) 56 | _T5 = identity 57 | 58 | _T6 :: forall a b c d e z. Iso' (T6 a b c d e z) (Product a (T5 b c d e z)) 59 | _T6 = identity 60 | 61 | _T7 :: forall a b c d e f z. Iso' (T7 a b c d e f z) (Product a (T6 b c d e f z)) 62 | _T7 = identity 63 | 64 | _T8 :: forall a b c d e f g z. Iso' (T8 a b c d e f g z) (Product a (T7 b c d e f g z)) 65 | _T8 = identity 66 | 67 | _T9 :: forall a b c d e f g h z. Iso' (T9 a b c d e f g h z) (Product a (T8 b c d e f g h z)) 68 | _T9 = identity 69 | 70 | _T10 71 | :: forall a b c d e f g h i z. Iso' (T10 a b c d e f g h i z) (Product a (T9 b c d e f g h i z)) 72 | _T10 = identity 73 | 74 | _T11 75 | :: forall a b c d e f g h i j z 76 | . Iso' (T11 a b c d e f g h i j z) (Product a (T10 b c d e f g h i j z)) 77 | _T11 = identity 78 | -------------------------------------------------------------------------------- /lenses/Data/Functor/Product2/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Functor.Product2.Lens where 2 | 3 | import Data.Functor.Product2 (Product2(..)) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso (iso) 6 | import Data.Tuple (Tuple(..)) 7 | 8 | _Product2 :: forall f g a b. Lens' (Product2 f g a b) (Tuple (f a b) (g a b)) 9 | _Product2 = iso (\(Product2 a b) -> Tuple a b) \(Tuple a b) -> Product2 a b 10 | -------------------------------------------------------------------------------- /lenses/Data/Generic/Rep/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Generic.Rep.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Generic.Rep (NoArguments(..), Product(..), Sum(..)) 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso (iso) 7 | import Data.Lens.Prism (Prism', prism) 8 | import Data.Tuple (Tuple(..)) 9 | import Prelude (Unit, const, unit) 10 | 11 | _NoArguments :: Lens' NoArguments Unit 12 | _NoArguments = iso (const unit) (const NoArguments) 13 | 14 | _Inl :: forall a b. Prism' (Sum a b) a 15 | _Inl = prism Inl case _ of 16 | Inl a -> Right a 17 | other -> Left other 18 | 19 | _Inr :: forall a b. Prism' (Sum a b) b 20 | _Inr = prism Inr case _ of 21 | Inr a -> Right a 22 | other -> Left other 23 | 24 | _Product :: forall a b. Lens' (Product a b) (Tuple a b) 25 | _Product = iso (\(Product a b) -> Tuple a b) \(Tuple a b) -> Product a b 26 | -------------------------------------------------------------------------------- /lenses/Data/Identity/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Identity.Lens where 2 | 3 | import Data.Identity (Identity) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Identity :: forall a. Lens' (Identity a) a 8 | _Identity = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Int/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Int.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Int (Parity(..)) 5 | import Data.Lens.Prism (Prism', prism) 6 | import Prelude (Unit, const, unit) 7 | 8 | _Even :: Prism' Parity Unit 9 | _Even = prism (const Even) case _ of 10 | Even -> Right unit 11 | other -> Left other 12 | 13 | _Odd :: Prism' Parity Unit 14 | _Odd = prism (const Odd) case _ of 15 | Odd -> Right unit 16 | other -> Left other 17 | -------------------------------------------------------------------------------- /lenses/Data/Interval/Duration/Iso/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Interval.Duration.Iso.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Interval.Duration (DurationComponent) 5 | import Data.Interval.Duration.Iso (Errors, Error(..)) 6 | import Data.Lens.Iso (Iso') 7 | import Data.Lens.Prism (Prism', prism) 8 | import Data.List.Types (NonEmptyList) 9 | import Prelude (Unit, const, identity, unit) 10 | 11 | _Errors :: Iso' Errors (NonEmptyList Error) 12 | _Errors = identity 13 | 14 | _IsEmpty :: Prism' Error Unit 15 | _IsEmpty = prism (const IsEmpty) case _ of 16 | IsEmpty -> Right unit 17 | other -> Left other 18 | 19 | _InvalidWeekComponentUsage :: Prism' Error Unit 20 | _InvalidWeekComponentUsage = prism (const InvalidWeekComponentUsage) case _ of 21 | InvalidWeekComponentUsage -> Right unit 22 | other -> Left other 23 | 24 | _ContainsNegativeValue :: Prism' Error DurationComponent 25 | _ContainsNegativeValue = prism ContainsNegativeValue case _ of 26 | ContainsNegativeValue a -> Right a 27 | other -> Left other 28 | 29 | _InvalidFractionalUse :: Prism' Error DurationComponent 30 | _InvalidFractionalUse = prism InvalidFractionalUse case _ of 31 | InvalidFractionalUse a -> Right a 32 | other -> Left other 33 | -------------------------------------------------------------------------------- /lenses/Data/Interval/Duration/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Interval.Duration.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Interval.Duration (Duration, DurationComponent(..)) 7 | import Data.Lens (Lens') 8 | import Data.Lens.Iso.Newtype (_Newtype) 9 | import Data.Lens.Prism (Prism', prism) 10 | import Data.Map as Map 11 | import Prelude (Unit, const, unit) 12 | 13 | _Duration :: Lens' Duration (Map.Map DurationComponent Number) 14 | _Duration = _Newtype 15 | 16 | _Second :: Prism' DurationComponent Unit 17 | _Second = prism (const Second) case _ of 18 | Second -> Right unit 19 | other -> Left other 20 | 21 | _Minute :: Prism' DurationComponent Unit 22 | _Minute = prism (const Minute) case _ of 23 | Minute -> Right unit 24 | other -> Left other 25 | 26 | _Hour :: Prism' DurationComponent Unit 27 | _Hour = prism (const Hour) case _ of 28 | Hour -> Right unit 29 | other -> Left other 30 | 31 | _Day :: Prism' DurationComponent Unit 32 | _Day = prism (const Day) case _ of 33 | Day -> Right unit 34 | other -> Left other 35 | 36 | _Week :: Prism' DurationComponent Unit 37 | _Week = prism (const Week) case _ of 38 | Week -> Right unit 39 | other -> Left other 40 | 41 | _Month :: Prism' DurationComponent Unit 42 | _Month = prism (const Month) case _ of 43 | Month -> Right unit 44 | other -> Left other 45 | 46 | _Year :: Prism' DurationComponent Unit 47 | _Year = prism (const Year) case _ of 48 | Year -> Right unit 49 | other -> Left other 50 | -------------------------------------------------------------------------------- /lenses/Data/Interval/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Interval.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Interval (Interval(..), RecurringInterval(..)) 7 | import Data.Lens (Lens') 8 | import Data.Lens.Iso (iso) 9 | import Data.Lens.Prism (Prism', prism) 10 | import Data.Maybe (Maybe) 11 | import Data.Tuple (Tuple(..)) 12 | 13 | _RecurringInterval :: forall d a. Lens' (RecurringInterval d a) (Tuple (Maybe Int) (Interval d a)) 14 | _RecurringInterval = iso (\(RecurringInterval a b) -> Tuple a b) \(Tuple a b) -> RecurringInterval 15 | a 16 | b 17 | 18 | _StartEnd :: forall d a. Prism' (Interval d a) (Tuple a a) 19 | _StartEnd = prism (\(Tuple a b) -> StartEnd a b) case _ of 20 | StartEnd a b -> Right (Tuple a b) 21 | other -> Left other 22 | 23 | _DurationEnd :: forall d a. Prism' (Interval d a) (Tuple d a) 24 | _DurationEnd = prism (\(Tuple a b) -> DurationEnd a b) case _ of 25 | DurationEnd a b -> Right (Tuple a b) 26 | other -> Left other 27 | 28 | _StartDuration :: forall d a. Prism' (Interval d a) (Tuple a d) 29 | _StartDuration = prism (\(Tuple a b) -> StartDuration a b) case _ of 30 | StartDuration a b -> Right (Tuple a b) 31 | other -> Left other 32 | 33 | _DurationOnly :: forall d a. Prism' (Interval d a) d 34 | _DurationOnly = prism DurationOnly case _ of 35 | DurationOnly a -> Right a 36 | other -> Left other 37 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Exchange/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Exchange.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Internal.Exchange (Exchange(..)) 5 | import Data.Lens.Iso (iso) 6 | import Data.Tuple (Tuple(..)) 7 | 8 | _Exchange :: forall a b s t. Lens' (Exchange a b s t) (Tuple (s -> a) (b -> t)) 9 | _Exchange = iso (\(Exchange a b) -> Tuple a b) \(Tuple a b) -> Exchange a b 10 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Focusing/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Focusing.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Internal.Focusing (Focusing) 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Tuple (Tuple) 7 | 8 | _Focusing :: forall m s a. Lens' (Focusing m s a) (m (Tuple s a)) 9 | _Focusing = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Forget/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Forget.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Internal.Forget (Forget) 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Forget :: forall r a b. Lens' (Forget r a b) (a -> r) 8 | _Forget = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Grating/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Grating.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Internal.Grating (Grating) 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Grating :: forall a b s t. Lens' (Grating a b s t) (((s -> a) -> b) -> t) 8 | _Grating = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Indexed/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Indexed.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Internal.Indexed (Indexed) 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Tuple (Tuple) 7 | 8 | _Indexed :: forall p i s t. Lens' (Indexed p i s t) (p (Tuple i s) t) 9 | _Indexed = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Market/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Market.Lens where 2 | 3 | import Data.Either (Either) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Internal.Market (Market(..)) 6 | import Data.Lens.Iso (iso) 7 | import Data.Tuple (Tuple(..)) 8 | 9 | _Market :: forall a b s t. Lens' (Market a b s t) (Tuple (b -> t) (s -> Either t a)) 10 | _Market = iso (\(Market a b) -> Tuple a b) \(Tuple a b) -> Market a b 11 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Re/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Re.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Internal.Re (Re) 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Re :: forall p s t a b. Lens' (Re p s t a b) (p b a -> p t s) 8 | _Re = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Shop/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Shop.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Internal.Shop (Shop(..)) 5 | import Data.Lens.Iso (iso) 6 | import Data.Tuple (Tuple(..)) 7 | 8 | _Shop :: forall a b s t. Lens' (Shop a b s t) (Tuple (s -> a) (s -> b -> t)) 9 | _Shop = iso (\(Shop a b) -> Tuple a b) \(Tuple a b) -> Shop a b 10 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Stall/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Stall.Lens where 2 | 3 | import Data.Either (Either) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Internal.Stall (Stall(..)) 6 | import Data.Lens.Iso (iso) 7 | import Data.Tuple (Tuple(..)) 8 | 9 | _Stall :: forall a b s t. Lens' (Stall a b s t) (Tuple (s -> b -> t) (s -> Either t a)) 10 | _Stall = iso (\(Stall a b) -> Tuple a b) \(Tuple a b) -> Stall a b 11 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Tagged/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Tagged.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Internal.Tagged (Tagged) 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Tagged :: forall a b. Lens' (Tagged a b) b 8 | _Tagged = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Lens/Internal/Zipping/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Lens.Internal.Zipping.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Internal.Zipping (Zipping) 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | 7 | _Zipping :: forall a b. Lens' (Zipping a b) (a -> a -> b) 8 | _Zipping = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/List/Lazy/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.List.Lazy.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.List.Lazy (Pattern) 6 | import Data.List.Lazy.Types (List) 7 | 8 | _Pattern :: forall a. Lens' (Pattern a) (List a) 9 | _Pattern = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/List/Lazy/Types/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.List.Lazy.Types.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lazy (Lazy) 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso.Newtype (_Newtype) 7 | import Data.Lens.Prism (Prism', prism) 8 | import Data.List.Lazy.Types (List, NonEmptyList, Step(..)) 9 | import Data.NonEmpty (NonEmpty) 10 | import Data.Tuple (Tuple(..)) 11 | import Prelude (Unit, const, unit) 12 | 13 | _List :: forall a. Lens' (List a) (Lazy (Step a)) 14 | _List = _Newtype 15 | 16 | _Nil :: forall a. Prism' (Step a) Unit 17 | _Nil = prism (const Nil) case _ of 18 | Nil -> Right unit 19 | other -> Left other 20 | 21 | _Cons :: forall a. Prism' (Step a) (Tuple a (List a)) 22 | _Cons = prism (\(Tuple a b) -> Cons a b) case _ of 23 | Cons a b -> Right (Tuple a b) 24 | other -> Left other 25 | 26 | _NonEmptyList :: forall a. Lens' (NonEmptyList a) (Lazy (NonEmpty List a)) 27 | _NonEmptyList = _Newtype 28 | -------------------------------------------------------------------------------- /lenses/Data/List/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.List.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.List (Pattern) 6 | import Data.List.Types (List) 7 | 8 | _Pattern :: forall a. Lens' (Pattern a) (List a) 9 | _Pattern = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/List/Types/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.List.Types.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Lens.Prism (Prism', prism) 7 | import Data.List.Types (NonEmptyList, List(..)) 8 | import Data.NonEmpty (NonEmpty) 9 | import Data.Tuple (Tuple(..)) 10 | import Prelude (Unit, const, unit) 11 | 12 | _Nil :: forall a. Prism' (List a) Unit 13 | _Nil = prism (const Nil) case _ of 14 | Nil -> Right unit 15 | other -> Left other 16 | 17 | _Cons :: forall a. Prism' (List a) (Tuple a (List a)) 18 | _Cons = prism (\(Tuple a b) -> Cons a b) case _ of 19 | Cons a b -> Right (Tuple a b) 20 | other -> Left other 21 | 22 | _NonEmptyList :: forall a. Lens' (NonEmptyList a) (NonEmpty List a) 23 | _NonEmptyList = _Newtype 24 | -------------------------------------------------------------------------------- /lenses/Data/List/ZipList/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.List.ZipList.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.List.Lazy (List) 6 | import Data.List.ZipList (ZipList) 7 | 8 | _ZipList :: forall a. Lens' (ZipList a) (List a) 9 | _ZipList = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/Map/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Map.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.Map (SemigroupMap) 6 | import Data.Map.Internal (Map) 7 | 8 | _SemigroupMap :: forall k v. Lens' (SemigroupMap k v) (Map k v) 9 | _SemigroupMap = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/Maybe/First/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Maybe.First.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.Maybe (Maybe) 6 | import Data.Maybe.First (First) 7 | 8 | _First :: forall a. Lens' (First a) (Maybe a) 9 | _First = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/Maybe/Last/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Maybe.Last.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.Maybe (Maybe) 6 | import Data.Maybe.Last (Last) 7 | 8 | _Last :: forall a. Lens' (Last a) (Maybe a) 9 | _Last = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/Maybe/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Maybe.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Prism (Prism', prism) 5 | import Data.Maybe (Maybe(..)) 6 | import Prelude (Unit, const, unit) 7 | 8 | _Nothing :: forall a. Prism' (Maybe a) Unit 9 | _Nothing = prism (const Nothing) case _ of 10 | Nothing -> Right unit 11 | other -> Left other 12 | 13 | _Just :: forall a. Prism' (Maybe a) a 14 | _Just = prism Just case _ of 15 | Just a -> Right a 16 | other -> Left other 17 | -------------------------------------------------------------------------------- /lenses/Data/Monoid/Alternate/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Monoid.Alternate.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.Monoid.Alternate (Alternate) 6 | 7 | _Alternate :: forall f a. Lens' (Alternate f a) (f a) 8 | _Alternate = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/NaturalTransformation/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.NaturalTransformation.Lens where 2 | 3 | import Data.Lens.Iso (Iso') 4 | import Data.NaturalTransformation (NaturalTransformation) 5 | import Prelude (identity) 6 | 7 | _NaturalTransformation :: forall f g. Iso' (NaturalTransformation f g) (forall a. f a -> g a) 8 | _NaturalTransformation = identity 9 | -------------------------------------------------------------------------------- /lenses/Data/NonEmpty/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.NonEmpty.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Data.NonEmpty (NonEmpty(..)) 6 | import Data.Tuple (Tuple(..)) 7 | 8 | _NonEmpty :: forall f a. Lens' (NonEmpty f a) (Tuple a (f a)) 9 | _NonEmpty = iso (\(NonEmpty a b) -> Tuple a b) \(Tuple a b) -> NonEmpty a b 10 | -------------------------------------------------------------------------------- /lenses/Data/Op/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Op.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.Op (Op) 6 | 7 | _Op :: forall a b. Lens' (Op a b) (b -> a) 8 | _Op = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Ord/Down/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Ord.Down.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.Ord.Down (Down) 6 | 7 | _Down :: forall a. Lens' (Down a) a 8 | _Down = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Ord/Max/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Ord.Max.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.Ord.Max (Max) 6 | 7 | _Max :: forall a. Lens' (Max a) a 8 | _Max = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Ord/Min/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Ord.Min.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.Ord.Min (Min) 6 | 7 | _Min :: forall a. Lens' (Min a) a 8 | _Min = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Ordering/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Ordering.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Prism (Prism', prism) 5 | import Data.Ordering (Ordering(..)) 6 | import Prelude (Unit, const, unit) 7 | 8 | _LT :: Prism' Ordering Unit 9 | _LT = prism (const LT) case _ of 10 | LT -> Right unit 11 | other -> Left other 12 | 13 | _GT :: Prism' Ordering Unit 14 | _GT = prism (const GT) case _ of 15 | GT -> Right unit 16 | other -> Left other 17 | 18 | _EQ :: Prism' Ordering Unit 19 | _EQ = prism (const EQ) case _ of 20 | EQ -> Right unit 21 | other -> Left other 22 | -------------------------------------------------------------------------------- /lenses/Data/Posix/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Posix.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso.Newtype (_Newtype) 7 | import Data.Posix (Gid, Pid, Uid) 8 | 9 | _Pid :: Lens' Pid Int 10 | _Pid = _Newtype 11 | 12 | _Gid :: Lens' Gid Int 13 | _Gid = _Newtype 14 | 15 | _Uid :: Lens' Uid Int 16 | _Uid = _Newtype 17 | -------------------------------------------------------------------------------- /lenses/Data/Posix/Signal/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Posix.Signal.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Prism (Prism', prism) 5 | import Data.Posix.Signal (Signal(..)) 6 | import Prelude (Unit, const, unit) 7 | 8 | _SIGABRT :: Prism' Signal Unit 9 | _SIGABRT = prism (const SIGABRT) case _ of 10 | SIGABRT -> Right unit 11 | other -> Left other 12 | 13 | _SIGALRM :: Prism' Signal Unit 14 | _SIGALRM = prism (const SIGALRM) case _ of 15 | SIGALRM -> Right unit 16 | other -> Left other 17 | 18 | _SIGBUS :: Prism' Signal Unit 19 | _SIGBUS = prism (const SIGBUS) case _ of 20 | SIGBUS -> Right unit 21 | other -> Left other 22 | 23 | _SIGCHLD :: Prism' Signal Unit 24 | _SIGCHLD = prism (const SIGCHLD) case _ of 25 | SIGCHLD -> Right unit 26 | other -> Left other 27 | 28 | _SIGCLD :: Prism' Signal Unit 29 | _SIGCLD = prism (const SIGCLD) case _ of 30 | SIGCLD -> Right unit 31 | other -> Left other 32 | 33 | _SIGCONT :: Prism' Signal Unit 34 | _SIGCONT = prism (const SIGCONT) case _ of 35 | SIGCONT -> Right unit 36 | other -> Left other 37 | 38 | _SIGEMT :: Prism' Signal Unit 39 | _SIGEMT = prism (const SIGEMT) case _ of 40 | SIGEMT -> Right unit 41 | other -> Left other 42 | 43 | _SIGFPE :: Prism' Signal Unit 44 | _SIGFPE = prism (const SIGFPE) case _ of 45 | SIGFPE -> Right unit 46 | other -> Left other 47 | 48 | _SIGHUP :: Prism' Signal Unit 49 | _SIGHUP = prism (const SIGHUP) case _ of 50 | SIGHUP -> Right unit 51 | other -> Left other 52 | 53 | _SIGILL :: Prism' Signal Unit 54 | _SIGILL = prism (const SIGILL) case _ of 55 | SIGILL -> Right unit 56 | other -> Left other 57 | 58 | _SIGINFO :: Prism' Signal Unit 59 | _SIGINFO = prism (const SIGINFO) case _ of 60 | SIGINFO -> Right unit 61 | other -> Left other 62 | 63 | _SIGINT :: Prism' Signal Unit 64 | _SIGINT = prism (const SIGINT) case _ of 65 | SIGINT -> Right unit 66 | other -> Left other 67 | 68 | _SIGIO :: Prism' Signal Unit 69 | _SIGIO = prism (const SIGIO) case _ of 70 | SIGIO -> Right unit 71 | other -> Left other 72 | 73 | _SIGIOT :: Prism' Signal Unit 74 | _SIGIOT = prism (const SIGIOT) case _ of 75 | SIGIOT -> Right unit 76 | other -> Left other 77 | 78 | _SIGKILL :: Prism' Signal Unit 79 | _SIGKILL = prism (const SIGKILL) case _ of 80 | SIGKILL -> Right unit 81 | other -> Left other 82 | 83 | _SIGLOST :: Prism' Signal Unit 84 | _SIGLOST = prism (const SIGLOST) case _ of 85 | SIGLOST -> Right unit 86 | other -> Left other 87 | 88 | _SIGPIPE :: Prism' Signal Unit 89 | _SIGPIPE = prism (const SIGPIPE) case _ of 90 | SIGPIPE -> Right unit 91 | other -> Left other 92 | 93 | _SIGPOLL :: Prism' Signal Unit 94 | _SIGPOLL = prism (const SIGPOLL) case _ of 95 | SIGPOLL -> Right unit 96 | other -> Left other 97 | 98 | _SIGPROF :: Prism' Signal Unit 99 | _SIGPROF = prism (const SIGPROF) case _ of 100 | SIGPROF -> Right unit 101 | other -> Left other 102 | 103 | _SIGPWR :: Prism' Signal Unit 104 | _SIGPWR = prism (const SIGPWR) case _ of 105 | SIGPWR -> Right unit 106 | other -> Left other 107 | 108 | _SIGQUIT :: Prism' Signal Unit 109 | _SIGQUIT = prism (const SIGQUIT) case _ of 110 | SIGQUIT -> Right unit 111 | other -> Left other 112 | 113 | _SIGSEGV :: Prism' Signal Unit 114 | _SIGSEGV = prism (const SIGSEGV) case _ of 115 | SIGSEGV -> Right unit 116 | other -> Left other 117 | 118 | _SIGSTKFLT :: Prism' Signal Unit 119 | _SIGSTKFLT = prism (const SIGSTKFLT) case _ of 120 | SIGSTKFLT -> Right unit 121 | other -> Left other 122 | 123 | _SIGSTOP :: Prism' Signal Unit 124 | _SIGSTOP = prism (const SIGSTOP) case _ of 125 | SIGSTOP -> Right unit 126 | other -> Left other 127 | 128 | _SIGSYS :: Prism' Signal Unit 129 | _SIGSYS = prism (const SIGSYS) case _ of 130 | SIGSYS -> Right unit 131 | other -> Left other 132 | 133 | _SIGTERM :: Prism' Signal Unit 134 | _SIGTERM = prism (const SIGTERM) case _ of 135 | SIGTERM -> Right unit 136 | other -> Left other 137 | 138 | _SIGTRAP :: Prism' Signal Unit 139 | _SIGTRAP = prism (const SIGTRAP) case _ of 140 | SIGTRAP -> Right unit 141 | other -> Left other 142 | 143 | _SIGTSTP :: Prism' Signal Unit 144 | _SIGTSTP = prism (const SIGTSTP) case _ of 145 | SIGTSTP -> Right unit 146 | other -> Left other 147 | 148 | _SIGTTIN :: Prism' Signal Unit 149 | _SIGTTIN = prism (const SIGTTIN) case _ of 150 | SIGTTIN -> Right unit 151 | other -> Left other 152 | 153 | _SIGTTOU :: Prism' Signal Unit 154 | _SIGTTOU = prism (const SIGTTOU) case _ of 155 | SIGTTOU -> Right unit 156 | other -> Left other 157 | 158 | _SIGUNUSED :: Prism' Signal Unit 159 | _SIGUNUSED = prism (const SIGUNUSED) case _ of 160 | SIGUNUSED -> Right unit 161 | other -> Left other 162 | 163 | _SIGURG :: Prism' Signal Unit 164 | _SIGURG = prism (const SIGURG) case _ of 165 | SIGURG -> Right unit 166 | other -> Left other 167 | 168 | _SIGUSR1 :: Prism' Signal Unit 169 | _SIGUSR1 = prism (const SIGUSR1) case _ of 170 | SIGUSR1 -> Right unit 171 | other -> Left other 172 | 173 | _SIGUSR2 :: Prism' Signal Unit 174 | _SIGUSR2 = prism (const SIGUSR2) case _ of 175 | SIGUSR2 -> Right unit 176 | other -> Left other 177 | 178 | _SIGVTALRM :: Prism' Signal Unit 179 | _SIGVTALRM = prism (const SIGVTALRM) case _ of 180 | SIGVTALRM -> Right unit 181 | other -> Left other 182 | 183 | _SIGWINCH :: Prism' Signal Unit 184 | _SIGWINCH = prism (const SIGWINCH) case _ of 185 | SIGWINCH -> Right unit 186 | other -> Left other 187 | 188 | _SIGXCPU :: Prism' Signal Unit 189 | _SIGXCPU = prism (const SIGXCPU) case _ of 190 | SIGXCPU -> Right unit 191 | other -> Left other 192 | 193 | _SIGXFSZ :: Prism' Signal Unit 194 | _SIGXFSZ = prism (const SIGXFSZ) case _ of 195 | SIGXFSZ -> Right unit 196 | other -> Left other 197 | -------------------------------------------------------------------------------- /lenses/Data/Predicate/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Predicate.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso.Newtype (_Newtype) 7 | import Data.Predicate (Predicate) 8 | 9 | _Predicate :: forall a. Lens' (Predicate a) (a -> Boolean) 10 | _Predicate = _Newtype 11 | -------------------------------------------------------------------------------- /lenses/Data/Profunctor/Join/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Profunctor.Join.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.Profunctor.Join (Join) 6 | 7 | _Join :: forall p a. Lens' (Join p a) (p a a) 8 | _Join = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/Profunctor/Star/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Profunctor.Star.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.Profunctor.Star (Star) 6 | 7 | _Star :: forall f a b. Lens' (Star f a b) (a -> f b) 8 | _Star = _Newtype 9 | -------------------------------------------------------------------------------- /lenses/Data/String/CaseInsensitive/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.String.CaseInsensitive.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso.Newtype (_Newtype) 7 | import Data.String.CaseInsensitive (CaseInsensitiveString) 8 | 9 | _CaseInsensitiveString :: Lens' CaseInsensitiveString String 10 | _CaseInsensitiveString = _Newtype 11 | -------------------------------------------------------------------------------- /lenses/Data/String/NonEmpty/CaseInsensitive/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.String.NonEmpty.CaseInsensitive.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso.Newtype (_Newtype) 5 | import Data.String.NonEmpty (NonEmptyString) 6 | import Data.String.NonEmpty.CaseInsensitive (CaseInsensitiveNonEmptyString) 7 | 8 | _CaseInsensitiveNonEmptyString :: Lens' CaseInsensitiveNonEmptyString NonEmptyString 9 | _CaseInsensitiveNonEmptyString = _Newtype 10 | -------------------------------------------------------------------------------- /lenses/Data/String/Pattern/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.String.Pattern.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso.Newtype (_Newtype) 7 | import Data.String.Pattern (Pattern, Replacement) 8 | 9 | _Pattern :: Lens' Pattern String 10 | _Pattern = _Newtype 11 | 12 | _Replacement :: Lens' Replacement String 13 | _Replacement = _Newtype 14 | -------------------------------------------------------------------------------- /lenses/Data/String/Regex/Flags/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.String.Regex.Flags.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso (Iso', iso) 7 | import Data.String.Regex.Flags (RegexFlagsRec, RegexFlags(..)) 8 | import Prelude (identity) 9 | 10 | _RegexFlagsRec :: Iso' RegexFlagsRec 11 | { global :: Boolean 12 | , ignoreCase :: Boolean 13 | , multiline :: Boolean 14 | , dotAll :: Boolean 15 | , sticky :: Boolean 16 | , unicode :: Boolean 17 | } 18 | _RegexFlagsRec = identity 19 | 20 | _RegexFlags :: Lens' RegexFlags RegexFlagsRec 21 | _RegexFlags = iso (\(RegexFlags a) -> a) RegexFlags 22 | -------------------------------------------------------------------------------- /lenses/Data/Symbol/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Symbol.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Data.Symbol (SProxy(..)) 6 | import Prelude (Unit, const, unit) 7 | 8 | _SProxy :: forall sym. Lens' (SProxy sym) Unit 9 | _SProxy = iso (const unit) (const SProxy) 10 | -------------------------------------------------------------------------------- /lenses/Data/Time/Duration/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Time.Duration.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso.Newtype (_Newtype) 7 | import Data.Time.Duration (Days, Hours, Milliseconds, Minutes, Seconds) 8 | 9 | _Milliseconds :: Lens' Milliseconds Number 10 | _Milliseconds = _Newtype 11 | 12 | _Seconds :: Lens' Seconds Number 13 | _Seconds = _Newtype 14 | 15 | _Minutes :: Lens' Minutes Number 16 | _Minutes = _Newtype 17 | 18 | _Hours :: Lens' Hours Number 19 | _Hours = _Newtype 20 | 21 | _Days :: Lens' Days Number 22 | _Days = _Newtype 23 | -------------------------------------------------------------------------------- /lenses/Data/Time/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Time.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Data.Time (Time(..)) 6 | import Data.Time.Component (Hour, Millisecond, Minute, Second) 7 | 8 | _Time :: Lens' Time { arg1 :: Hour, arg2 :: Minute, arg3 :: Second, arg4 :: Millisecond } 9 | _Time = iso (\(Time arg1 arg2 arg3 arg4) -> { arg1: arg1, arg2: arg2, arg3: arg3, arg4: arg4 }) 10 | \{ arg1, arg2, arg3, arg4 } -> Time arg1 arg2 arg3 arg4 11 | -------------------------------------------------------------------------------- /lenses/Data/Traversable/Accum/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Traversable.Accum.Lens where 2 | 3 | import Data.Lens.Iso (Iso') 4 | import Data.Traversable.Accum (Accum) 5 | import Prelude (identity) 6 | 7 | _Accum :: forall s a. Iso' (Accum s a) { accum :: s, value :: a } 8 | _Accum = identity 9 | -------------------------------------------------------------------------------- /lenses/Data/Tuple/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Tuple.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Data.Tuple (Tuple(..)) 6 | 7 | _Tuple :: forall a b. Lens' (Tuple a b) (Tuple a b) 8 | _Tuple = iso (\(Tuple a b) -> Tuple a b) \(Tuple a b) -> Tuple a b 9 | -------------------------------------------------------------------------------- /lenses/Data/Tuple/Nested/Lens.purs: -------------------------------------------------------------------------------- 1 | module Data.Tuple.Nested.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens.Iso (Iso') 6 | import Data.Tuple (Tuple) 7 | import Data.Tuple.Nested (T10, T11, T2, T3, T4, T5, T6, T7, T8, T9, Tuple1, Tuple10, Tuple2, Tuple3, Tuple4, Tuple5, Tuple6, Tuple7, Tuple8, Tuple9) 8 | import Prelude (identity) 9 | 10 | _Tuple1 :: forall a. Iso' (Tuple1 a) (T2 a Unit) 11 | _Tuple1 = identity 12 | 13 | _Tuple2 :: forall a b. Iso' (Tuple2 a b) (T3 a b Unit) 14 | _Tuple2 = identity 15 | 16 | _Tuple3 :: forall a b c. Iso' (Tuple3 a b c) (T4 a b c Unit) 17 | _Tuple3 = identity 18 | 19 | _Tuple4 :: forall a b c d. Iso' (Tuple4 a b c d) (T5 a b c d Unit) 20 | _Tuple4 = identity 21 | 22 | _Tuple5 :: forall a b c d e. Iso' (Tuple5 a b c d e) (T6 a b c d e Unit) 23 | _Tuple5 = identity 24 | 25 | _Tuple6 :: forall a b c d e f. Iso' (Tuple6 a b c d e f) (T7 a b c d e f Unit) 26 | _Tuple6 = identity 27 | 28 | _Tuple7 :: forall a b c d e f g. Iso' (Tuple7 a b c d e f g) (T8 a b c d e f g Unit) 29 | _Tuple7 = identity 30 | 31 | _Tuple8 :: forall a b c d e f g h. Iso' (Tuple8 a b c d e f g h) (T9 a b c d e f g h Unit) 32 | _Tuple8 = identity 33 | 34 | _Tuple9 :: forall a b c d e f g h i. Iso' (Tuple9 a b c d e f g h i) (T10 a b c d e f g h i Unit) 35 | _Tuple9 = identity 36 | 37 | _Tuple10 38 | :: forall a b c d e f g h i j. Iso' (Tuple10 a b c d e f g h i j) (T11 a b c d e f g h i j Unit) 39 | _Tuple10 = identity 40 | 41 | _T2 :: forall a z. Iso' (T2 a z) (Tuple a z) 42 | _T2 = identity 43 | 44 | _T3 :: forall a b z. Iso' (T3 a b z) (Tuple a (T2 b z)) 45 | _T3 = identity 46 | 47 | _T4 :: forall a b c z. Iso' (T4 a b c z) (Tuple a (T3 b c z)) 48 | _T4 = identity 49 | 50 | _T5 :: forall a b c d z. Iso' (T5 a b c d z) (Tuple a (T4 b c d z)) 51 | _T5 = identity 52 | 53 | _T6 :: forall a b c d e z. Iso' (T6 a b c d e z) (Tuple a (T5 b c d e z)) 54 | _T6 = identity 55 | 56 | _T7 :: forall a b c d e f z. Iso' (T7 a b c d e f z) (Tuple a (T6 b c d e f z)) 57 | _T7 = identity 58 | 59 | _T8 :: forall a b c d e f g z. Iso' (T8 a b c d e f g z) (Tuple a (T7 b c d e f g z)) 60 | _T8 = identity 61 | 62 | _T9 :: forall a b c d e f g h z. Iso' (T9 a b c d e f g h z) (Tuple a (T8 b c d e f g h z)) 63 | _T9 = identity 64 | 65 | _T10 :: forall a b c d e f g h i z. Iso' (T10 a b c d e f g h i z) (Tuple a (T9 b c d e f g h i z)) 66 | _T10 = identity 67 | 68 | _T11 69 | :: forall a b c d e f g h i j z 70 | . Iso' (T11 a b c d e f g h i j z) (Tuple a (T10 b c d e f g h i j z)) 71 | _T11 = identity 72 | -------------------------------------------------------------------------------- /lenses/Dodo/Internal/Lens.purs: -------------------------------------------------------------------------------- 1 | module Dodo.Internal.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Lens.Iso (Iso') 7 | import Data.Lens.Prism (Prism', prism) 8 | import Data.Tuple (Tuple(..)) 9 | import Dodo.Internal (LocalOptions, Position, Doc(..)) 10 | import Prelude (Unit, const, identity, unit) 11 | 12 | _Position :: Iso' Position 13 | { line :: Int 14 | , column :: Int 15 | , indent :: Int 16 | , nextIndent :: Int 17 | , pageWidth :: Int 18 | , ribbonWidth :: Int 19 | } 20 | _Position = identity 21 | 22 | _Append :: forall a. Prism' (Doc a) (Tuple (Doc a) (Doc a)) 23 | _Append = prism (\(Tuple a b) -> Append a b) case _ of 24 | Append a b -> Right (Tuple a b) 25 | other -> Left other 26 | 27 | _Indent :: forall a. Prism' (Doc a) (Doc a) 28 | _Indent = prism Indent case _ of 29 | Indent a -> Right a 30 | other -> Left other 31 | 32 | _Align :: forall a. Prism' (Doc a) (Tuple Int (Doc a)) 33 | _Align = prism (\(Tuple a b) -> Align a b) case _ of 34 | Align a b -> Right (Tuple a b) 35 | other -> Left other 36 | 37 | _Annotate :: forall a. Prism' (Doc a) (Tuple a (Doc a)) 38 | _Annotate = prism (\(Tuple a b) -> Annotate a b) case _ of 39 | Annotate a b -> Right (Tuple a b) 40 | other -> Left other 41 | 42 | _FlexSelect :: forall a. Prism' (Doc a) { arg1 :: (Doc a), arg2 :: (Doc a), arg3 :: (Doc a) } 43 | _FlexSelect = prism (\{ arg1, arg2, arg3 } -> FlexSelect arg1 arg2 arg3) case _ of 44 | FlexSelect arg1 arg2 arg3 -> Right { arg1: arg1, arg2: arg2, arg3: arg3 } 45 | other -> Left other 46 | 47 | _FlexAlt :: forall a. Prism' (Doc a) (Tuple (Doc a) (Doc a)) 48 | _FlexAlt = prism (\(Tuple a b) -> FlexAlt a b) case _ of 49 | FlexAlt a b -> Right (Tuple a b) 50 | other -> Left other 51 | 52 | _WithPosition :: forall a. Prism' (Doc a) (Position -> Doc a) 53 | _WithPosition = prism WithPosition case _ of 54 | WithPosition a -> Right a 55 | other -> Left other 56 | 57 | _Local :: forall a. Prism' (Doc a) (Tuple (LocalOptions -> LocalOptions) (Doc a)) 58 | _Local = prism (\(Tuple a b) -> Local a b) case _ of 59 | Local a b -> Right (Tuple a b) 60 | other -> Left other 61 | 62 | _Text :: forall a. Prism' (Doc a) (Tuple Int String) 63 | _Text = prism (\(Tuple a b) -> Text a b) case _ of 64 | Text a b -> Right (Tuple a b) 65 | other -> Left other 66 | 67 | _Break :: forall a. Prism' (Doc a) Unit 68 | _Break = prism (const Break) case _ of 69 | Break -> Right unit 70 | other -> Left other 71 | 72 | _Empty :: forall a. Prism' (Doc a) Unit 73 | _Empty = prism (const Empty) case _ of 74 | Empty -> Right unit 75 | other -> Left other 76 | 77 | _LocalOptions :: Iso' LocalOptions 78 | { indent :: Int 79 | , indentSpaces :: String 80 | , indentUnit :: String 81 | , indentWidth :: Int 82 | , pageWidth :: Int 83 | , ribbonRatio :: Number 84 | } 85 | _LocalOptions = identity 86 | -------------------------------------------------------------------------------- /lenses/Dodo/Lens.purs: -------------------------------------------------------------------------------- 1 | module Dodo.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens.Iso (Iso') 6 | import Dodo (PrintOptions) 7 | import Prelude (identity) 8 | 9 | _PrintOptions :: Iso' PrintOptions 10 | { pageWidth :: Int 11 | , ribbonRatio :: Number 12 | , indentUnit :: String 13 | , indentWidth :: Int 14 | } 15 | _PrintOptions = identity 16 | -------------------------------------------------------------------------------- /lenses/Effect/AVar/Lens.purs: -------------------------------------------------------------------------------- 1 | module Effect.AVar.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Lens.Iso (Iso') 7 | import Data.Lens.Prism (Prism', prism) 8 | import Effect (Effect) 9 | import Effect.AVar (AVarCallback, AVarStatus(..)) 10 | import Effect.Exception (Error) 11 | import Prelude (Unit, const, identity, unit) 12 | 13 | _AVarCallback :: forall a. Iso' (AVarCallback a) (Either Error a → Effect Unit) 14 | _AVarCallback = identity 15 | 16 | _Killed :: forall a. Prism' (AVarStatus a) Error 17 | _Killed = prism Killed case _ of 18 | Killed a -> Right a 19 | other -> Left other 20 | 21 | _Filled :: forall a. Prism' (AVarStatus a) a 22 | _Filled = prism Filled case _ of 23 | Filled a -> Right a 24 | other -> Left other 25 | 26 | _Empty :: forall a. Prism' (AVarStatus a) Unit 27 | _Empty = prism (const Empty) case _ of 28 | Empty -> Right unit 29 | other -> Left other 30 | -------------------------------------------------------------------------------- /lenses/Effect/Aff/Compat/Lens.purs: -------------------------------------------------------------------------------- 1 | module Effect.Aff.Compat.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens.Iso (Iso') 6 | import Effect.Aff.Compat (EffectFnCb) 7 | import Effect.Uncurried (EffectFn1) 8 | import Prelude (identity) 9 | 10 | _EffectFnCb :: forall a. Iso' (EffectFnCb a) (EffectFn1 a Unit) 11 | _EffectFnCb = identity 12 | -------------------------------------------------------------------------------- /lenses/Effect/Aff/Lens.purs: -------------------------------------------------------------------------------- 1 | module Effect.Aff.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso (Iso') 7 | import Data.Lens.Iso.Newtype (_Newtype) 8 | import Effect.Aff (Aff, BracketConditions, Canceler) 9 | import Effect.Exception (Error) 10 | import Prelude (identity) 11 | 12 | _Canceler :: Lens' Canceler (Error → Aff Unit) 13 | _Canceler = _Newtype 14 | 15 | _BracketConditions 16 | :: forall a b 17 | . Iso' (BracketConditions a b) 18 | { killed ∷ Error → a → Aff Unit 19 | , failed ∷ Error → a → Aff Unit 20 | , completed ∷ b → a → Aff Unit 21 | } 22 | _BracketConditions = identity 23 | -------------------------------------------------------------------------------- /lenses/Foreign/Lens.purs: -------------------------------------------------------------------------------- 1 | module Foreign.Lens where 2 | 3 | import Prelude 4 | 5 | import Control.Monad.Except (Except, ExceptT) 6 | import Data.Either (Either(..)) 7 | import Data.Lens.Iso (Iso') 8 | import Data.Lens.Prism (Prism', prism) 9 | import Data.List.NonEmpty (NonEmptyList) 10 | import Data.Tuple (Tuple(..)) 11 | import Foreign (F, FT, MultipleErrors, ForeignError(..)) 12 | import Prelude (identity) 13 | 14 | _ForeignError :: Prism' ForeignError String 15 | _ForeignError = prism ForeignError case _ of 16 | ForeignError a -> Right a 17 | other -> Left other 18 | 19 | _TypeMismatch :: Prism' ForeignError (Tuple String String) 20 | _TypeMismatch = prism (\(Tuple a b) -> TypeMismatch a b) case _ of 21 | TypeMismatch a b -> Right (Tuple a b) 22 | other -> Left other 23 | 24 | _ErrorAtIndex :: Prism' ForeignError (Tuple Int ForeignError) 25 | _ErrorAtIndex = prism (\(Tuple a b) -> ErrorAtIndex a b) case _ of 26 | ErrorAtIndex a b -> Right (Tuple a b) 27 | other -> Left other 28 | 29 | _ErrorAtProperty :: Prism' ForeignError (Tuple String ForeignError) 30 | _ErrorAtProperty = prism (\(Tuple a b) -> ErrorAtProperty a b) case _ of 31 | ErrorAtProperty a b -> Right (Tuple a b) 32 | other -> Left other 33 | 34 | _MultipleErrors :: Iso' MultipleErrors (NonEmptyList ForeignError) 35 | _MultipleErrors = identity 36 | 37 | _F :: Iso' F (Except MultipleErrors) 38 | _F = identity 39 | 40 | _FT :: Iso' FT (ExceptT MultipleErrors) 41 | _FT = identity 42 | -------------------------------------------------------------------------------- /lenses/Math/Lens.purs: -------------------------------------------------------------------------------- 1 | module Math.Lens where 2 | 3 | import Data.Lens.Iso (Iso') 4 | import Math (Radians) 5 | import Prelude (identity) 6 | 7 | _Radians :: Iso' Radians Number 8 | _Radians = identity 9 | -------------------------------------------------------------------------------- /lenses/Node/Buffer/Types/Lens.purs: -------------------------------------------------------------------------------- 1 | module Node.Buffer.Types.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Lens.Iso (Iso') 7 | import Data.Lens.Prism (Prism', prism) 8 | import Node.Buffer.Types (Octet, Offset, BufferValueType(..)) 9 | import Prelude (Unit, const, identity, unit) 10 | 11 | _Octet :: Iso' Octet Int 12 | _Octet = identity 13 | 14 | _Offset :: Iso' Offset Int 15 | _Offset = identity 16 | 17 | _UInt8 :: Prism' BufferValueType Unit 18 | _UInt8 = prism (const UInt8) case _ of 19 | UInt8 -> Right unit 20 | other -> Left other 21 | 22 | _UInt16LE :: Prism' BufferValueType Unit 23 | _UInt16LE = prism (const UInt16LE) case _ of 24 | UInt16LE -> Right unit 25 | other -> Left other 26 | 27 | _UInt16BE :: Prism' BufferValueType Unit 28 | _UInt16BE = prism (const UInt16BE) case _ of 29 | UInt16BE -> Right unit 30 | other -> Left other 31 | 32 | _UInt32LE :: Prism' BufferValueType Unit 33 | _UInt32LE = prism (const UInt32LE) case _ of 34 | UInt32LE -> Right unit 35 | other -> Left other 36 | 37 | _UInt32BE :: Prism' BufferValueType Unit 38 | _UInt32BE = prism (const UInt32BE) case _ of 39 | UInt32BE -> Right unit 40 | other -> Left other 41 | 42 | _Int8 :: Prism' BufferValueType Unit 43 | _Int8 = prism (const Int8) case _ of 44 | Int8 -> Right unit 45 | other -> Left other 46 | 47 | _Int16LE :: Prism' BufferValueType Unit 48 | _Int16LE = prism (const Int16LE) case _ of 49 | Int16LE -> Right unit 50 | other -> Left other 51 | 52 | _Int16BE :: Prism' BufferValueType Unit 53 | _Int16BE = prism (const Int16BE) case _ of 54 | Int16BE -> Right unit 55 | other -> Left other 56 | 57 | _Int32LE :: Prism' BufferValueType Unit 58 | _Int32LE = prism (const Int32LE) case _ of 59 | Int32LE -> Right unit 60 | other -> Left other 61 | 62 | _Int32BE :: Prism' BufferValueType Unit 63 | _Int32BE = prism (const Int32BE) case _ of 64 | Int32BE -> Right unit 65 | other -> Left other 66 | 67 | _FloatLE :: Prism' BufferValueType Unit 68 | _FloatLE = prism (const FloatLE) case _ of 69 | FloatLE -> Right unit 70 | other -> Left other 71 | 72 | _FloatBE :: Prism' BufferValueType Unit 73 | _FloatBE = prism (const FloatBE) case _ of 74 | FloatBE -> Right unit 75 | other -> Left other 76 | 77 | _DoubleLE :: Prism' BufferValueType Unit 78 | _DoubleLE = prism (const DoubleLE) case _ of 79 | DoubleLE -> Right unit 80 | other -> Left other 81 | 82 | _DoubleBE :: Prism' BufferValueType Unit 83 | _DoubleBE = prism (const DoubleBE) case _ of 84 | DoubleBE -> Right unit 85 | other -> Left other 86 | -------------------------------------------------------------------------------- /lenses/Node/ChildProcess/Lens.purs: -------------------------------------------------------------------------------- 1 | module Node.ChildProcess.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Lens.Iso (Iso') 7 | import Data.Lens.Prism (Prism', prism) 8 | import Data.Maybe (Maybe) 9 | import Data.Posix (Gid, Uid) 10 | import Data.Posix.Signal (Signal) 11 | import Effect.Exception as Exception 12 | import Foreign.Object (Object) 13 | import Node.Buffer (Buffer) 14 | import Node.ChildProcess (Error, ExecOptions, ExecResult, ExecSyncOptions, SpawnOptions, Exit(..), StdIOBehaviour(..)) 15 | import Node.Encoding (Encoding) 16 | import Node.FS as FS 17 | import Node.Stream (Stream) 18 | import Prelude (Unit, const, identity, unit) 19 | 20 | _Normally :: Prism' Exit Int 21 | _Normally = prism Normally case _ of 22 | Normally a -> Right a 23 | other -> Left other 24 | 25 | _BySignal :: Prism' Exit Signal 26 | _BySignal = prism BySignal case _ of 27 | BySignal a -> Right a 28 | other -> Left other 29 | 30 | _SpawnOptions :: Iso' SpawnOptions 31 | { cwd :: Maybe String 32 | , stdio :: Array (Maybe StdIOBehaviour) 33 | , env :: Maybe (Object String) 34 | , detached :: Boolean 35 | , uid :: Maybe Uid 36 | , gid :: Maybe Gid 37 | } 38 | _SpawnOptions = identity 39 | 40 | _ExecOptions :: Iso' ExecOptions 41 | { cwd :: Maybe String 42 | , env :: Maybe (Object String) 43 | , encoding :: Maybe Encoding 44 | , shell :: Maybe String 45 | , timeout :: Maybe Number 46 | , maxBuffer :: Maybe Int 47 | , killSignal :: Maybe Signal 48 | , uid :: Maybe Uid 49 | , gid :: Maybe Gid 50 | } 51 | _ExecOptions = identity 52 | 53 | _ExecResult :: Iso' ExecResult 54 | { stderr :: Buffer 55 | , stdout :: Buffer 56 | , error :: Maybe Exception.Error 57 | } 58 | _ExecResult = identity 59 | 60 | _ExecSyncOptions :: Iso' ExecSyncOptions 61 | { cwd :: Maybe String 62 | , input :: Maybe String 63 | , stdio :: Array (Maybe StdIOBehaviour) 64 | , env :: Maybe (Object String) 65 | , timeout :: Maybe Number 66 | , maxBuffer :: Maybe Int 67 | , killSignal :: Maybe Signal 68 | , uid :: Maybe Uid 69 | , gid :: Maybe Gid 70 | } 71 | _ExecSyncOptions = identity 72 | 73 | _Error :: Iso' Error 74 | { code :: String 75 | , errno :: String 76 | , syscall :: String 77 | } 78 | _Error = identity 79 | 80 | _Pipe :: Prism' StdIOBehaviour Unit 81 | _Pipe = prism (const Pipe) case _ of 82 | Pipe -> Right unit 83 | other -> Left other 84 | 85 | _Ignore :: Prism' StdIOBehaviour Unit 86 | _Ignore = prism (const Ignore) case _ of 87 | Ignore -> Right unit 88 | other -> Left other 89 | 90 | _ShareStream :: Prism' StdIOBehaviour (forall r. Stream r) 91 | _ShareStream = prism ShareStream case _ of 92 | ShareStream a -> Right a 93 | other -> Left other 94 | 95 | _ShareFD :: Prism' StdIOBehaviour FS.FileDescriptor 96 | _ShareFD = prism ShareFD case _ of 97 | ShareFD a -> Right a 98 | other -> Left other 99 | -------------------------------------------------------------------------------- /lenses/Node/Encoding/Lens.purs: -------------------------------------------------------------------------------- 1 | module Node.Encoding.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Prism (Prism', prism) 5 | import Node.Encoding (Encoding(..)) 6 | import Prelude (Unit, const, unit) 7 | 8 | _ASCII :: Prism' Encoding Unit 9 | _ASCII = prism (const ASCII) case _ of 10 | ASCII -> Right unit 11 | other -> Left other 12 | 13 | _UTF8 :: Prism' Encoding Unit 14 | _UTF8 = prism (const UTF8) case _ of 15 | UTF8 -> Right unit 16 | other -> Left other 17 | 18 | _UTF16LE :: Prism' Encoding Unit 19 | _UTF16LE = prism (const UTF16LE) case _ of 20 | UTF16LE -> Right unit 21 | other -> Left other 22 | 23 | _UCS2 :: Prism' Encoding Unit 24 | _UCS2 = prism (const UCS2) case _ of 25 | UCS2 -> Right unit 26 | other -> Left other 27 | 28 | _Base64 :: Prism' Encoding Unit 29 | _Base64 = prism (const Base64) case _ of 30 | Base64 -> Right unit 31 | other -> Left other 32 | 33 | _Latin1 :: Prism' Encoding Unit 34 | _Latin1 = prism (const Latin1) case _ of 35 | Latin1 -> Right unit 36 | other -> Left other 37 | 38 | _Binary :: Prism' Encoding Unit 39 | _Binary = prism (const Binary) case _ of 40 | Binary -> Right unit 41 | other -> Left other 42 | 43 | _Hex :: Prism' Encoding Unit 44 | _Hex = prism (const Hex) case _ of 45 | Hex -> Right unit 46 | other -> Left other 47 | -------------------------------------------------------------------------------- /lenses/Node/FS/Async/Lens.purs: -------------------------------------------------------------------------------- 1 | module Node.FS.Async.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either) 6 | import Data.Lens.Iso (Iso') 7 | import Effect (Effect) 8 | import Effect.Exception (Error) 9 | import Node.FS.Async (Callback) 10 | import Prelude (identity) 11 | 12 | _Callback :: forall a. Iso' (Callback a) (Either Error a -> Effect Unit) 13 | _Callback = identity 14 | -------------------------------------------------------------------------------- /lenses/Node/FS/Lens.purs: -------------------------------------------------------------------------------- 1 | module Node.FS.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Lens.Iso (Iso') 7 | import Data.Lens.Prism (Prism', prism) 8 | import Node.FS (BufferLength, BufferOffset, ByteCount, FileMode, FilePosition, FileFlags(..), SymlinkType(..)) 9 | import Prelude (Unit, const, identity, unit) 10 | 11 | _R :: Prism' FileFlags Unit 12 | _R = prism (const R) case _ of 13 | R -> Right unit 14 | other -> Left other 15 | 16 | _R_PLUS :: Prism' FileFlags Unit 17 | _R_PLUS = prism (const R_PLUS) case _ of 18 | R_PLUS -> Right unit 19 | other -> Left other 20 | 21 | _RS :: Prism' FileFlags Unit 22 | _RS = prism (const RS) case _ of 23 | RS -> Right unit 24 | other -> Left other 25 | 26 | _RS_PLUS :: Prism' FileFlags Unit 27 | _RS_PLUS = prism (const RS_PLUS) case _ of 28 | RS_PLUS -> Right unit 29 | other -> Left other 30 | 31 | _W :: Prism' FileFlags Unit 32 | _W = prism (const W) case _ of 33 | W -> Right unit 34 | other -> Left other 35 | 36 | _WX :: Prism' FileFlags Unit 37 | _WX = prism (const WX) case _ of 38 | WX -> Right unit 39 | other -> Left other 40 | 41 | _W_PLUS :: Prism' FileFlags Unit 42 | _W_PLUS = prism (const W_PLUS) case _ of 43 | W_PLUS -> Right unit 44 | other -> Left other 45 | 46 | _WX_PLUS :: Prism' FileFlags Unit 47 | _WX_PLUS = prism (const WX_PLUS) case _ of 48 | WX_PLUS -> Right unit 49 | other -> Left other 50 | 51 | _A :: Prism' FileFlags Unit 52 | _A = prism (const A) case _ of 53 | A -> Right unit 54 | other -> Left other 55 | 56 | _AX :: Prism' FileFlags Unit 57 | _AX = prism (const AX) case _ of 58 | AX -> Right unit 59 | other -> Left other 60 | 61 | _A_PLUS :: Prism' FileFlags Unit 62 | _A_PLUS = prism (const A_PLUS) case _ of 63 | A_PLUS -> Right unit 64 | other -> Left other 65 | 66 | _AX_PLUS :: Prism' FileFlags Unit 67 | _AX_PLUS = prism (const AX_PLUS) case _ of 68 | AX_PLUS -> Right unit 69 | other -> Left other 70 | 71 | _FileMode :: Iso' FileMode Int 72 | _FileMode = identity 73 | 74 | _FilePosition :: Iso' FilePosition Int 75 | _FilePosition = identity 76 | 77 | _BufferLength :: Iso' BufferLength Int 78 | _BufferLength = identity 79 | 80 | _BufferOffset :: Iso' BufferOffset Int 81 | _BufferOffset = identity 82 | 83 | _ByteCount :: Iso' ByteCount Int 84 | _ByteCount = identity 85 | 86 | _FileLink :: Prism' SymlinkType Unit 87 | _FileLink = prism (const FileLink) case _ of 88 | FileLink -> Right unit 89 | other -> Left other 90 | 91 | _DirLink :: Prism' SymlinkType Unit 92 | _DirLink = prism (const DirLink) case _ of 93 | DirLink -> Right unit 94 | other -> Left other 95 | 96 | _JunctionLink :: Prism' SymlinkType Unit 97 | _JunctionLink = prism (const JunctionLink) case _ of 98 | JunctionLink -> Right unit 99 | other -> Left other 100 | -------------------------------------------------------------------------------- /lenses/Node/FS/Stats/Lens.purs: -------------------------------------------------------------------------------- 1 | module Node.FS.Stats.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Function.Uncurried (Fn0) 6 | import Data.JSDate (JSDate) 7 | import Data.Lens (Lens') 8 | import Data.Lens.Iso (Iso', iso) 9 | import Node.FS.Stats (StatsObj, Stats(..)) 10 | import Prelude (identity) 11 | 12 | _StatsObj :: Iso' StatsObj 13 | { dev :: Number 14 | , mode :: Number 15 | , nlink :: Number 16 | , uid :: Number 17 | , gid :: Number 18 | , rdev :: Number 19 | , ino :: Number 20 | , size :: Number 21 | , atime :: JSDate 22 | , mtime :: JSDate 23 | , ctime :: JSDate 24 | , isFile :: Fn0 Boolean 25 | , isDirectory :: Fn0 Boolean 26 | , isBlockDevice :: Fn0 Boolean 27 | , isCharacterDevice :: Fn0 Boolean 28 | , isFIFO :: Fn0 Boolean 29 | , isSocket :: Fn0 Boolean 30 | } 31 | _StatsObj = identity 32 | 33 | _Stats :: Lens' Stats StatsObj 34 | _Stats = iso (\(Stats a) -> a) Stats 35 | -------------------------------------------------------------------------------- /lenses/Node/FS/Stream/Lens.purs: -------------------------------------------------------------------------------- 1 | module Node.FS.Stream.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens.Iso (Iso') 6 | import Node.FS (FileFlags) 7 | import Node.FS.Perms (Perms) 8 | import Node.FS.Stream (ReadStreamOptions, WriteStreamOptions) 9 | import Prelude (identity) 10 | 11 | _WriteStreamOptions :: Iso' WriteStreamOptions 12 | { flags :: FileFlags 13 | , perms :: Perms 14 | } 15 | _WriteStreamOptions = identity 16 | 17 | _ReadStreamOptions :: Iso' ReadStreamOptions 18 | { flags :: FileFlags 19 | , perms :: Perms 20 | , autoClose :: Boolean 21 | } 22 | _ReadStreamOptions = identity 23 | -------------------------------------------------------------------------------- /lenses/Node/Path/Lens.purs: -------------------------------------------------------------------------------- 1 | module Node.Path.Lens where 2 | 3 | import Data.Lens.Iso (Iso') 4 | import Node.Path (FilePath) 5 | import Prelude (identity) 6 | 7 | _FilePath :: Iso' FilePath String 8 | _FilePath = identity 9 | -------------------------------------------------------------------------------- /lenses/Node/Platform/Lens.purs: -------------------------------------------------------------------------------- 1 | module Node.Platform.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Prism (Prism', prism) 5 | import Node.Platform (Platform(..)) 6 | import Prelude (Unit, const, unit) 7 | 8 | _AIX :: Prism' Platform Unit 9 | _AIX = prism (const AIX) case _ of 10 | AIX -> Right unit 11 | other -> Left other 12 | 13 | _Darwin :: Prism' Platform Unit 14 | _Darwin = prism (const Darwin) case _ of 15 | Darwin -> Right unit 16 | other -> Left other 17 | 18 | _FreeBSD :: Prism' Platform Unit 19 | _FreeBSD = prism (const FreeBSD) case _ of 20 | FreeBSD -> Right unit 21 | other -> Left other 22 | 23 | _Linux :: Prism' Platform Unit 24 | _Linux = prism (const Linux) case _ of 25 | Linux -> Right unit 26 | other -> Left other 27 | 28 | _OpenBSD :: Prism' Platform Unit 29 | _OpenBSD = prism (const OpenBSD) case _ of 30 | OpenBSD -> Right unit 31 | other -> Left other 32 | 33 | _SunOS :: Prism' Platform Unit 34 | _SunOS = prism (const SunOS) case _ of 35 | SunOS -> Right unit 36 | other -> Left other 37 | 38 | _Win32 :: Prism' Platform Unit 39 | _Win32 = prism (const Win32) case _ of 40 | Win32 -> Right unit 41 | other -> Left other 42 | 43 | _Android :: Prism' Platform Unit 44 | _Android = prism (const Android) case _ of 45 | Android -> Right unit 46 | other -> Left other 47 | -------------------------------------------------------------------------------- /lenses/Node/Stream/Lens.purs: -------------------------------------------------------------------------------- 1 | module Node.Stream.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens.Iso (Iso') 6 | import Node.Stream (Duplex, Readable, Stream, Writable) 7 | import Prelude (identity) 8 | 9 | _Readable :: forall r. Iso' (Readable r) (Stream (read :: Read | r)) 10 | _Readable = identity 11 | 12 | _Writable :: forall r. Iso' (Writable r) (Stream (write :: Write | r)) 13 | _Writable = identity 14 | 15 | _Duplex :: Iso' Duplex (Stream (read :: Read, write :: Write)) 16 | _Duplex = identity 17 | -------------------------------------------------------------------------------- /lenses/PureScript/CST/Errors/Lens.purs: -------------------------------------------------------------------------------- 1 | module PureScript.CST.Errors.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Lens.Prism (Prism', prism) 7 | import Data.Tuple (Tuple(..)) 8 | import Prelude (Unit, const, unit) 9 | import PureScript.CST.Errors (ParseError(..)) 10 | import PureScript.CST.Types (Token) 11 | 12 | _UnexpectedEof :: Prism' ParseError Unit 13 | _UnexpectedEof = prism (const UnexpectedEof) case _ of 14 | UnexpectedEof -> Right unit 15 | other -> Left other 16 | 17 | _ExpectedEof :: Prism' ParseError Token 18 | _ExpectedEof = prism ExpectedEof case _ of 19 | ExpectedEof a -> Right a 20 | other -> Left other 21 | 22 | _UnexpectedToken :: Prism' ParseError Token 23 | _UnexpectedToken = prism UnexpectedToken case _ of 24 | UnexpectedToken a -> Right a 25 | other -> Left other 26 | 27 | _ExpectedToken :: Prism' ParseError (Tuple Token Token) 28 | _ExpectedToken = prism (\(Tuple a b) -> ExpectedToken a b) case _ of 29 | ExpectedToken a b -> Right (Tuple a b) 30 | other -> Left other 31 | 32 | _ExpectedClass :: Prism' ParseError (Tuple String Token) 33 | _ExpectedClass = prism (\(Tuple a b) -> ExpectedClass a b) case _ of 34 | ExpectedClass a b -> Right (Tuple a b) 35 | other -> Left other 36 | 37 | _LexExpected :: Prism' ParseError (Tuple String String) 38 | _LexExpected = prism (\(Tuple a b) -> LexExpected a b) case _ of 39 | LexExpected a b -> Right (Tuple a b) 40 | other -> Left other 41 | 42 | _LexInvalidCharEscape :: Prism' ParseError String 43 | _LexInvalidCharEscape = prism LexInvalidCharEscape case _ of 44 | LexInvalidCharEscape a -> Right a 45 | other -> Left other 46 | 47 | _LexCharEscapeOutOfRange :: Prism' ParseError String 48 | _LexCharEscapeOutOfRange = prism LexCharEscapeOutOfRange case _ of 49 | LexCharEscapeOutOfRange a -> Right a 50 | other -> Left other 51 | 52 | _LexHexOutOfRange :: Prism' ParseError String 53 | _LexHexOutOfRange = prism LexHexOutOfRange case _ of 54 | LexHexOutOfRange a -> Right a 55 | other -> Left other 56 | 57 | _LexIntOutOfRange :: Prism' ParseError String 58 | _LexIntOutOfRange = prism LexIntOutOfRange case _ of 59 | LexIntOutOfRange a -> Right a 60 | other -> Left other 61 | 62 | _LexNumberOutOfRange :: Prism' ParseError String 63 | _LexNumberOutOfRange = prism LexNumberOutOfRange case _ of 64 | LexNumberOutOfRange a -> Right a 65 | other -> Left other 66 | -------------------------------------------------------------------------------- /lenses/PureScript/CST/Layout/Lens.purs: -------------------------------------------------------------------------------- 1 | module PureScript.CST.Layout.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Iso (Iso') 5 | import Data.Lens.Prism (Prism', prism) 6 | import Data.List (List) 7 | import Data.Tuple (Tuple) 8 | import Prelude (Unit, const, identity, unit) 9 | import PureScript.CST.Layout (LayoutStack, LayoutDelim(..)) 10 | import PureScript.CST.Types (SourcePos) 11 | 12 | _LayoutStack :: Iso' LayoutStack (List (Tuple SourcePos LayoutDelim)) 13 | _LayoutStack = identity 14 | 15 | _LytRoot :: Prism' LayoutDelim Unit 16 | _LytRoot = prism (const LytRoot) case _ of 17 | LytRoot -> Right unit 18 | other -> Left other 19 | 20 | _LytTopDecl :: Prism' LayoutDelim Unit 21 | _LytTopDecl = prism (const LytTopDecl) case _ of 22 | LytTopDecl -> Right unit 23 | other -> Left other 24 | 25 | _LytTopDeclHead :: Prism' LayoutDelim Unit 26 | _LytTopDeclHead = prism (const LytTopDeclHead) case _ of 27 | LytTopDeclHead -> Right unit 28 | other -> Left other 29 | 30 | _LytDeclGuard :: Prism' LayoutDelim Unit 31 | _LytDeclGuard = prism (const LytDeclGuard) case _ of 32 | LytDeclGuard -> Right unit 33 | other -> Left other 34 | 35 | _LytCase :: Prism' LayoutDelim Unit 36 | _LytCase = prism (const LytCase) case _ of 37 | LytCase -> Right unit 38 | other -> Left other 39 | 40 | _LytCaseBinders :: Prism' LayoutDelim Unit 41 | _LytCaseBinders = prism (const LytCaseBinders) case _ of 42 | LytCaseBinders -> Right unit 43 | other -> Left other 44 | 45 | _LytCaseGuard :: Prism' LayoutDelim Unit 46 | _LytCaseGuard = prism (const LytCaseGuard) case _ of 47 | LytCaseGuard -> Right unit 48 | other -> Left other 49 | 50 | _LytLambdaBinders :: Prism' LayoutDelim Unit 51 | _LytLambdaBinders = prism (const LytLambdaBinders) case _ of 52 | LytLambdaBinders -> Right unit 53 | other -> Left other 54 | 55 | _LytParen :: Prism' LayoutDelim Unit 56 | _LytParen = prism (const LytParen) case _ of 57 | LytParen -> Right unit 58 | other -> Left other 59 | 60 | _LytBrace :: Prism' LayoutDelim Unit 61 | _LytBrace = prism (const LytBrace) case _ of 62 | LytBrace -> Right unit 63 | other -> Left other 64 | 65 | _LytSquare :: Prism' LayoutDelim Unit 66 | _LytSquare = prism (const LytSquare) case _ of 67 | LytSquare -> Right unit 68 | other -> Left other 69 | 70 | _LytIf :: Prism' LayoutDelim Unit 71 | _LytIf = prism (const LytIf) case _ of 72 | LytIf -> Right unit 73 | other -> Left other 74 | 75 | _LytThen :: Prism' LayoutDelim Unit 76 | _LytThen = prism (const LytThen) case _ of 77 | LytThen -> Right unit 78 | other -> Left other 79 | 80 | _LytProperty :: Prism' LayoutDelim Unit 81 | _LytProperty = prism (const LytProperty) case _ of 82 | LytProperty -> Right unit 83 | other -> Left other 84 | 85 | _LytForall :: Prism' LayoutDelim Unit 86 | _LytForall = prism (const LytForall) case _ of 87 | LytForall -> Right unit 88 | other -> Left other 89 | 90 | _LytTick :: Prism' LayoutDelim Unit 91 | _LytTick = prism (const LytTick) case _ of 92 | LytTick -> Right unit 93 | other -> Left other 94 | 95 | _LytLet :: Prism' LayoutDelim Unit 96 | _LytLet = prism (const LytLet) case _ of 97 | LytLet -> Right unit 98 | other -> Left other 99 | 100 | _LytLetStmt :: Prism' LayoutDelim Unit 101 | _LytLetStmt = prism (const LytLetStmt) case _ of 102 | LytLetStmt -> Right unit 103 | other -> Left other 104 | 105 | _LytWhere :: Prism' LayoutDelim Unit 106 | _LytWhere = prism (const LytWhere) case _ of 107 | LytWhere -> Right unit 108 | other -> Left other 109 | 110 | _LytOf :: Prism' LayoutDelim Unit 111 | _LytOf = prism (const LytOf) case _ of 112 | LytOf -> Right unit 113 | other -> Left other 114 | 115 | _LytDo :: Prism' LayoutDelim Unit 116 | _LytDo = prism (const LytDo) case _ of 117 | LytDo -> Right unit 118 | other -> Left other 119 | 120 | _LytAdo :: Prism' LayoutDelim Unit 121 | _LytAdo = prism (const LytAdo) case _ of 122 | LytAdo -> Right unit 123 | other -> Left other 124 | -------------------------------------------------------------------------------- /lenses/PureScript/CST/Lens.purs: -------------------------------------------------------------------------------- 1 | module PureScript.CST.Lens where 2 | 3 | import Prelude 4 | 5 | import Prim hiding (Type) 6 | 7 | import Data.Array.NonEmpty (NonEmptyArray) 8 | import Data.Either (Either(..)) 9 | import Data.Lens.Prism (Prism', prism) 10 | import Data.Tuple (Tuple(..)) 11 | import PureScript.CST (RecoveredParserResult(..)) 12 | import PureScript.CST.Parser (Recovered) 13 | import PureScript.CST.Parser.Monad (PositionedError) 14 | 15 | _ParseSucceeded :: forall f. Prism' (RecoveredParserResult f) (f Void) 16 | _ParseSucceeded = prism ParseSucceeded case _ of 17 | ParseSucceeded a -> Right a 18 | other -> Left other 19 | 20 | _ParseSucceededWithErrors 21 | :: forall f 22 | . Prism' (RecoveredParserResult f) (Tuple (Recovered f) (NonEmptyArray PositionedError)) 23 | _ParseSucceededWithErrors = prism (\(Tuple a b) -> ParseSucceededWithErrors a b) case _ of 24 | ParseSucceededWithErrors a b -> Right (Tuple a b) 25 | other -> Left other 26 | 27 | _ParseFailed :: forall f. Prism' (RecoveredParserResult f) PositionedError 28 | _ParseFailed = prism ParseFailed case _ of 29 | ParseFailed a -> Right a 30 | other -> Left other 31 | -------------------------------------------------------------------------------- /lenses/PureScript/CST/ModuleGraph/Lens.purs: -------------------------------------------------------------------------------- 1 | module PureScript.CST.ModuleGraph.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Lens.Prism (Prism', prism) 7 | import PureScript.CST.ModuleGraph (ModuleSort(..)) 8 | 9 | _Sorted :: forall a. Prism' (ModuleSort a) (Array a) 10 | _Sorted = prism Sorted case _ of 11 | Sorted a -> Right a 12 | other -> Left other 13 | 14 | _CycleDetected :: forall a. Prism' (ModuleSort a) (Array a) 15 | _CycleDetected = prism CycleDetected case _ of 16 | CycleDetected a -> Right a 17 | other -> Left other 18 | -------------------------------------------------------------------------------- /lenses/PureScript/CST/Parser/Lens.purs: -------------------------------------------------------------------------------- 1 | module PureScript.CST.Parser.Lens where 2 | 3 | import Data.Lens.Iso (Iso') 4 | import Prelude (identity) 5 | import PureScript.CST.Errors (RecoveredError) 6 | import PureScript.CST.Parser (Recovered) 7 | 8 | _Recovered :: forall f. Iso' (Recovered f) (f RecoveredError) 9 | _Recovered = identity 10 | -------------------------------------------------------------------------------- /lenses/PureScript/CST/Parser/Monad/Lens.purs: -------------------------------------------------------------------------------- 1 | module PureScript.CST.Parser.Monad.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Lens (Lens') 7 | import Data.Lens.Iso (Iso', iso) 8 | import Data.Lens.Prism (Prism', prism) 9 | import Data.Maybe (Maybe) 10 | import Data.Tuple (Tuple(..)) 11 | import Prelude (identity) 12 | import PureScript.CST.Errors (ParseError) 13 | import PureScript.CST.Parser.Monad (ParserState, PositionedError, ParserResult(..), Recovery(..)) 14 | import PureScript.CST.TokenStream (TokenStream) 15 | import PureScript.CST.Types (SourcePos) 16 | 17 | _PositionedError :: Iso' PositionedError 18 | { position :: SourcePos 19 | , error :: ParseError 20 | } 21 | _PositionedError = identity 22 | 23 | _Recovery :: forall a. Lens' (Recovery a) { arg1 :: a, arg2 :: SourcePos, arg3 :: TokenStream } 24 | _Recovery = iso (\(Recovery arg1 arg2 arg3) -> { arg1: arg1, arg2: arg2, arg3: arg3 }) 25 | \{ arg1, arg2, arg3 } -> Recovery arg1 arg2 arg3 26 | 27 | _ParseFail 28 | :: forall a 29 | . Prism' (ParserResult a) 30 | { arg1 :: ParseError, arg2 :: SourcePos, arg3 :: ParserState, arg4 :: (Maybe TokenStream) } 31 | _ParseFail = prism (\{ arg1, arg2, arg3, arg4 } -> ParseFail arg1 arg2 arg3 arg4) case _ of 32 | ParseFail arg1 arg2 arg3 arg4 -> Right { arg1: arg1, arg2: arg2, arg3: arg3, arg4: arg4 } 33 | other -> Left other 34 | 35 | _ParseSucc :: forall a. Prism' (ParserResult a) (Tuple a ParserState) 36 | _ParseSucc = prism (\(Tuple a b) -> ParseSucc a b) case _ of 37 | ParseSucc a b -> Right (Tuple a b) 38 | other -> Left other 39 | 40 | _ParserState :: Iso' ParserState 41 | { consumed :: Boolean 42 | , errors :: Array PositionedError 43 | , position :: SourcePos 44 | , stream :: TokenStream 45 | } 46 | _ParserState = identity 47 | -------------------------------------------------------------------------------- /lenses/PureScript/CST/Print/Lens.purs: -------------------------------------------------------------------------------- 1 | module PureScript.CST.Print.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Prism (Prism', prism) 5 | import Prelude (Unit, const, unit) 6 | import PureScript.CST.Print (TokenOption(..)) 7 | 8 | _ShowLayout :: Prism' TokenOption Unit 9 | _ShowLayout = prism (const ShowLayout) case _ of 10 | ShowLayout -> Right unit 11 | other -> Left other 12 | 13 | _HideLayout :: Prism' TokenOption Unit 14 | _HideLayout = prism (const HideLayout) case _ of 15 | HideLayout -> Right unit 16 | other -> Left other 17 | -------------------------------------------------------------------------------- /lenses/PureScript/CST/Range/TokenList/Lens.purs: -------------------------------------------------------------------------------- 1 | module PureScript.CST.Range.TokenList.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Prism (Prism', prism) 5 | import Data.Tuple (Tuple(..)) 6 | import Prelude (Unit, const, unit) 7 | import PureScript.CST.Range.TokenList (TokenList, UnconsToken(..)) 8 | import PureScript.CST.Types (SourceToken) 9 | 10 | _UnconsDone :: Prism' UnconsToken Unit 11 | _UnconsDone = prism (const UnconsDone) case _ of 12 | UnconsDone -> Right unit 13 | other -> Left other 14 | 15 | _UnconsMore :: Prism' UnconsToken (Tuple SourceToken TokenList) 16 | _UnconsMore = prism (\(Tuple a b) -> UnconsMore a b) case _ of 17 | UnconsMore a b -> Right (Tuple a b) 18 | other -> Left other 19 | -------------------------------------------------------------------------------- /lenses/PureScript/CST/TokenStream/Lens.purs: -------------------------------------------------------------------------------- 1 | module PureScript.CST.TokenStream.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Data.Lazy (Lazy) 7 | import Data.Lens (Lens') 8 | import Data.Lens.Iso.Newtype (_Newtype) 9 | import Data.Lens.Prism (Prism', prism) 10 | import Data.Maybe (Maybe) 11 | import Data.Tuple (Tuple(..)) 12 | import PureScript.CST.Errors (ParseError) 13 | import PureScript.CST.Layout (LayoutStack) 14 | import PureScript.CST.TokenStream (TokenStream, TokenStep(..)) 15 | import PureScript.CST.Types (Comment, LineFeed, SourcePos, SourceToken) 16 | 17 | _TokenStream :: Lens' TokenStream (Lazy TokenStep) 18 | _TokenStream = _Newtype 19 | 20 | _TokenEOF :: Prism' TokenStep (Tuple SourcePos (Array (Comment LineFeed))) 21 | _TokenEOF = prism (\(Tuple a b) -> TokenEOF a b) case _ of 22 | TokenEOF a b -> Right (Tuple a b) 23 | other -> Left other 24 | 25 | _TokenError :: Prism' TokenStep 26 | { arg1 :: SourcePos, arg2 :: ParseError, arg3 :: (Maybe TokenStream), arg4 :: LayoutStack } 27 | _TokenError = prism (\{ arg1, arg2, arg3, arg4 } -> TokenError arg1 arg2 arg3 arg4) case _ of 28 | TokenError arg1 arg2 arg3 arg4 -> Right { arg1: arg1, arg2: arg2, arg3: arg3, arg4: arg4 } 29 | other -> Left other 30 | 31 | _TokenCons :: Prism' TokenStep 32 | { arg1 :: SourceToken, arg2 :: SourcePos, arg3 :: TokenStream, arg4 :: LayoutStack } 33 | _TokenCons = prism (\{ arg1, arg2, arg3, arg4 } -> TokenCons arg1 arg2 arg3 arg4) case _ of 34 | TokenCons arg1 arg2 arg3 arg4 -> Right { arg1: arg1, arg2: arg2, arg3: arg3, arg4: arg4 } 35 | other -> Left other 36 | -------------------------------------------------------------------------------- /lenses/PureScript/CST/Traversal/Lens.purs: -------------------------------------------------------------------------------- 1 | module PureScript.CST.Traversal.Lens where 2 | 3 | import Data.Lens.Iso (Iso') 4 | import Data.Tuple (Tuple) 5 | import Prelude (identity) 6 | import PureScript.CST.Traversal (MonoidalRewrite, PureRewrite, PureRewriteWithContext, Rewrite, RewriteWithContext) 7 | 8 | _Rewrite :: forall e f g. Iso' (Rewrite e f g) (g e -> f (g e)) 9 | _Rewrite = identity 10 | 11 | _RewriteWithContext 12 | :: forall c e f g. Iso' (RewriteWithContext c e f g) (c -> g e -> f (Tuple c (g e))) 13 | _RewriteWithContext = identity 14 | 15 | _MonoidalRewrite :: forall e m g. Iso' (MonoidalRewrite e m g) (g e -> m) 16 | _MonoidalRewrite = identity 17 | 18 | _PureRewrite :: forall e g. Iso' (PureRewrite e g) (g e -> g e) 19 | _PureRewrite = identity 20 | 21 | _PureRewriteWithContext 22 | :: forall c e g. Iso' (PureRewriteWithContext c e g) (c -> g e -> Tuple c (g e)) 23 | _PureRewriteWithContext = identity 24 | -------------------------------------------------------------------------------- /lenses/RecordLens.purs: -------------------------------------------------------------------------------- 1 | module Dependencies.RecordLens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Record (prop) 5 | import Type.Proxy (Proxy(..)) 6 | 7 | _accum :: forall r a. Lens' { accum :: a | r } a 8 | _accum = prop (Proxy :: Proxy "accum") 9 | 10 | _arg1 :: forall r a. Lens' { arg1 :: a | r } a 11 | _arg1 = prop (Proxy :: Proxy "arg1") 12 | 13 | _arg2 :: forall r a. Lens' { arg2 :: a | r } a 14 | _arg2 = prop (Proxy :: Proxy "arg2") 15 | 16 | _arg3 :: forall r a. Lens' { arg3 :: a | r } a 17 | _arg3 = prop (Proxy :: Proxy "arg3") 18 | 19 | _arg4 :: forall r a. Lens' { arg4 :: a | r } a 20 | _arg4 = prop (Proxy :: Proxy "arg4") 21 | 22 | _arrow :: forall r a. Lens' { arrow :: a | r } a 23 | _arrow = prop (Proxy :: Proxy "arrow") 24 | 25 | _atime :: forall r a. Lens' { atime :: a | r } a 26 | _atime = prop (Proxy :: Proxy "atime") 27 | 28 | _autoClose :: forall r a. Lens' { autoClose :: a | r } a 29 | _autoClose = prop (Proxy :: Proxy "autoClose") 30 | 31 | _bar :: forall r a. Lens' { bar :: a | r } a 32 | _bar = prop (Proxy :: Proxy "bar") 33 | 34 | _binder :: forall r a. Lens' { binder :: a | r } a 35 | _binder = prop (Proxy :: Proxy "binder") 36 | 37 | _binders :: forall r a. Lens' { binders :: a | r } a 38 | _binders = prop (Proxy :: Proxy "binders") 39 | 40 | _bindings :: forall r a. Lens' { bindings :: a | r } a 41 | _bindings = prop (Proxy :: Proxy "bindings") 42 | 43 | _body :: forall r a. Lens' { body :: a | r } a 44 | _body = prop (Proxy :: Proxy "body") 45 | 46 | _branches :: forall r a. Lens' { branches :: a | r } a 47 | _branches = prop (Proxy :: Proxy "branches") 48 | 49 | _className :: forall r a. Lens' { className :: a | r } a 50 | _className = prop (Proxy :: Proxy "className") 51 | 52 | _close :: forall r a. Lens' { close :: a | r } a 53 | _close = prop (Proxy :: Proxy "close") 54 | 55 | _code :: forall r a. Lens' { code :: a | r } a 56 | _code = prop (Proxy :: Proxy "code") 57 | 58 | _column :: forall r a. Lens' { column :: a | r } a 59 | _column = prop (Proxy :: Proxy "column") 60 | 61 | _completed :: forall r a. Lens' { completed :: a | r } a 62 | _completed = prop (Proxy :: Proxy "completed") 63 | 64 | _cond :: forall r a. Lens' { cond :: a | r } a 65 | _cond = prop (Proxy :: Proxy "cond") 66 | 67 | _constraints :: forall r a. Lens' { constraints :: a | r } a 68 | _constraints = prop (Proxy :: Proxy "constraints") 69 | 70 | _consumed :: forall r a. Lens' { consumed :: a | r } a 71 | _consumed = prop (Proxy :: Proxy "consumed") 72 | 73 | _ctime :: forall r a. Lens' { ctime :: a | r } a 74 | _ctime = prop (Proxy :: Proxy "ctime") 75 | 76 | _cwd :: forall r a. Lens' { cwd :: a | r } a 77 | _cwd = prop (Proxy :: Proxy "cwd") 78 | 79 | _declarations :: forall r a. Lens' { declarations :: a | r } a 80 | _declarations = prop (Proxy :: Proxy "declarations") 81 | 82 | _decls :: forall r a. Lens' { decls :: a | r } a 83 | _decls = prop (Proxy :: Proxy "decls") 84 | 85 | _detached :: forall r a. Lens' { detached :: a | r } a 86 | _detached = prop (Proxy :: Proxy "detached") 87 | 88 | _dev :: forall r a. Lens' { dev :: a | r } a 89 | _dev = prop (Proxy :: Proxy "dev") 90 | 91 | _dot :: forall r a. Lens' { dot :: a | r } a 92 | _dot = prop (Proxy :: Proxy "dot") 93 | 94 | _dotAll :: forall r a. Lens' { dotAll :: a | r } a 95 | _dotAll = prop (Proxy :: Proxy "dotAll") 96 | 97 | _else :: forall r a. Lens' { else :: a | r } a 98 | _else = prop (Proxy :: Proxy "else") 99 | 100 | _encoding :: forall r a. Lens' { encoding :: a | r } a 101 | _encoding = prop (Proxy :: Proxy "encoding") 102 | 103 | _end :: forall r a. Lens' { end :: a | r } a 104 | _end = prop (Proxy :: Proxy "end") 105 | 106 | _env :: forall r a. Lens' { env :: a | r } a 107 | _env = prop (Proxy :: Proxy "env") 108 | 109 | _errno :: forall r a. Lens' { errno :: a | r } a 110 | _errno = prop (Proxy :: Proxy "errno") 111 | 112 | _error :: forall r a. Lens' { error :: a | r } a 113 | _error = prop (Proxy :: Proxy "error") 114 | 115 | _errors :: forall r a. Lens' { errors :: a | r } a 116 | _errors = prop (Proxy :: Proxy "errors") 117 | 118 | _exports :: forall r a. Lens' { exports :: a | r } a 119 | _exports = prop (Proxy :: Proxy "exports") 120 | 121 | _expr :: forall r a. Lens' { expr :: a | r } a 122 | _expr = prop (Proxy :: Proxy "expr") 123 | 124 | _failed :: forall r a. Lens' { failed :: a | r } a 125 | _failed = prop (Proxy :: Proxy "failed") 126 | 127 | _false :: forall r a. Lens' { false :: a | r } a 128 | _false = prop (Proxy :: Proxy "false") 129 | 130 | _fields :: forall r a. Lens' { fields :: a | r } a 131 | _fields = prop (Proxy :: Proxy "fields") 132 | 133 | _flags :: forall r a. Lens' { flags :: a | r } a 134 | _flags = prop (Proxy :: Proxy "flags") 135 | 136 | _fold :: forall r a. Lens' { fold :: a | r } a 137 | _fold = prop (Proxy :: Proxy "fold") 138 | 139 | _foldFull :: forall r a. Lens' { foldFull :: a | r } a 140 | _foldFull = prop (Proxy :: Proxy "foldFull") 141 | 142 | _formatError :: forall r a. Lens' { formatError :: a | r } a 143 | _formatError = prop (Proxy :: Proxy "formatError") 144 | 145 | _fundeps :: forall r a. Lens' { fundeps :: a | r } a 146 | _fundeps = prop (Proxy :: Proxy "fundeps") 147 | 148 | _gid :: forall r a. Lens' { gid :: a | r } a 149 | _gid = prop (Proxy :: Proxy "gid") 150 | 151 | _global :: forall r a. Lens' { global :: a | r } a 152 | _global = prop (Proxy :: Proxy "global") 153 | 154 | _guarded :: forall r a. Lens' { guarded :: a | r } a 155 | _guarded = prop (Proxy :: Proxy "guarded") 156 | 157 | _head :: forall r a. Lens' { head :: a | r } a 158 | _head = prop (Proxy :: Proxy "head") 159 | 160 | _header :: forall r a. Lens' { header :: a | r } a 161 | _header = prop (Proxy :: Proxy "header") 162 | 163 | _ignoreCase :: forall r a. Lens' { ignoreCase :: a | r } a 164 | _ignoreCase = prop (Proxy :: Proxy "ignoreCase") 165 | 166 | _importWrap :: forall r a. Lens' { importWrap :: a | r } a 167 | _importWrap = prop (Proxy :: Proxy "importWrap") 168 | 169 | _imports :: forall r a. Lens' { imports :: a | r } a 170 | _imports = prop (Proxy :: Proxy "imports") 171 | 172 | _importsFrom :: forall r a. Lens' { importsFrom :: a | r } a 173 | _importsFrom = prop (Proxy :: Proxy "importsFrom") 174 | 175 | _importsHiding :: forall r a. Lens' { importsHiding :: a | r } a 176 | _importsHiding = prop (Proxy :: Proxy "importsHiding") 177 | 178 | _importsHidingQualified :: forall r a. Lens' { importsHidingQualified :: a | r } a 179 | _importsHidingQualified = prop (Proxy :: Proxy "importsHidingQualified") 180 | 181 | _importsOpen :: forall r a. Lens' { importsOpen :: a | r } a 182 | _importsOpen = prop (Proxy :: Proxy "importsOpen") 183 | 184 | _importsQualified :: forall r a. Lens' { importsQualified :: a | r } a 185 | _importsQualified = prop (Proxy :: Proxy "importsQualified") 186 | 187 | _in :: forall r a. Lens' { in :: a | r } a 188 | _in = prop (Proxy :: Proxy "in") 189 | 190 | _indent :: forall r a. Lens' { indent :: a | r } a 191 | _indent = prop (Proxy :: Proxy "indent") 192 | 193 | _indentSpaces :: forall r a. Lens' { indentSpaces :: a | r } a 194 | _indentSpaces = prop (Proxy :: Proxy "indentSpaces") 195 | 196 | _indentUnit :: forall r a. Lens' { indentUnit :: a | r } a 197 | _indentUnit = prop (Proxy :: Proxy "indentUnit") 198 | 199 | _indentWidth :: forall r a. Lens' { indentWidth :: a | r } a 200 | _indentWidth = prop (Proxy :: Proxy "indentWidth") 201 | 202 | _index :: forall r a. Lens' { index :: a | r } a 203 | _index = prop (Proxy :: Proxy "index") 204 | 205 | _ino :: forall r a. Lens' { ino :: a | r } a 206 | _ino = prop (Proxy :: Proxy "ino") 207 | 208 | _input :: forall r a. Lens' { input :: a | r } a 209 | _input = prop (Proxy :: Proxy "input") 210 | 211 | _isBlockDevice :: forall r a. Lens' { isBlockDevice :: a | r } a 212 | _isBlockDevice = prop (Proxy :: Proxy "isBlockDevice") 213 | 214 | _isCharacterDevice :: forall r a. Lens' { isCharacterDevice :: a | r } a 215 | _isCharacterDevice = prop (Proxy :: Proxy "isCharacterDevice") 216 | 217 | _isDirectory :: forall r a. Lens' { isDirectory :: a | r } a 218 | _isDirectory = prop (Proxy :: Proxy "isDirectory") 219 | 220 | _isFIFO :: forall r a. Lens' { isFIFO :: a | r } a 221 | _isFIFO = prop (Proxy :: Proxy "isFIFO") 222 | 223 | _isFile :: forall r a. Lens' { isFile :: a | r } a 224 | _isFile = prop (Proxy :: Proxy "isFile") 225 | 226 | _isSocket :: forall r a. Lens' { isSocket :: a | r } a 227 | _isSocket = prop (Proxy :: Proxy "isSocket") 228 | 229 | _keyword :: forall r a. Lens' { keyword :: a | r } a 230 | _keyword = prop (Proxy :: Proxy "keyword") 231 | 232 | _killSignal :: forall r a. Lens' { killSignal :: a | r } a 233 | _killSignal = prop (Proxy :: Proxy "killSignal") 234 | 235 | _killed :: forall r a. Lens' { killed :: a | r } a 236 | _killed = prop (Proxy :: Proxy "killed") 237 | 238 | _label :: forall r a. Lens' { label :: a | r } a 239 | _label = prop (Proxy :: Proxy "label") 240 | 241 | _labels :: forall r a. Lens' { labels :: a | r } a 242 | _labels = prop (Proxy :: Proxy "labels") 243 | 244 | _leadingComments :: forall r a. Lens' { leadingComments :: a | r } a 245 | _leadingComments = prop (Proxy :: Proxy "leadingComments") 246 | 247 | _line :: forall r a. Lens' { line :: a | r } a 248 | _line = prop (Proxy :: Proxy "line") 249 | 250 | _lower :: forall r a. Lens' { lower :: a | r } a 251 | _lower = prop (Proxy :: Proxy "lower") 252 | 253 | _maxBuffer :: forall r a. Lens' { maxBuffer :: a | r } a 254 | _maxBuffer = prop (Proxy :: Proxy "maxBuffer") 255 | 256 | _mode :: forall r a. Lens' { mode :: a | r } a 257 | _mode = prop (Proxy :: Proxy "mode") 258 | 259 | _module :: forall r a. Lens' { module :: a | r } a 260 | _module = prop (Proxy :: Proxy "module") 261 | 262 | _mtime :: forall r a. Lens' { mtime :: a | r } a 263 | _mtime = prop (Proxy :: Proxy "mtime") 264 | 265 | _multiline :: forall r a. Lens' { multiline :: a | r } a 266 | _multiline = prop (Proxy :: Proxy "multiline") 267 | 268 | _name :: forall r a. Lens' { name :: a | r } a 269 | _name = prop (Proxy :: Proxy "name") 270 | 271 | _names :: forall r a. Lens' { names :: a | r } a 272 | _names = prop (Proxy :: Proxy "names") 273 | 274 | _nextIndent :: forall r a. Lens' { nextIndent :: a | r } a 275 | _nextIndent = prop (Proxy :: Proxy "nextIndent") 276 | 277 | _nlink :: forall r a. Lens' { nlink :: a | r } a 278 | _nlink = prop (Proxy :: Proxy "nlink") 279 | 280 | _of :: forall r a. Lens' { of :: a | r } a 281 | _of = prop (Proxy :: Proxy "of") 282 | 283 | _open :: forall r a. Lens' { open :: a | r } a 284 | _open = prop (Proxy :: Proxy "open") 285 | 286 | _operator :: forall r a. Lens' { operator :: a | r } a 287 | _operator = prop (Proxy :: Proxy "operator") 288 | 289 | _operators :: forall r a. Lens' { operators :: a | r } a 290 | _operators = prop (Proxy :: Proxy "operators") 291 | 292 | _pageWidth :: forall r a. Lens' { pageWidth :: a | r } a 293 | _pageWidth = prop (Proxy :: Proxy "pageWidth") 294 | 295 | _path :: forall r a. Lens' { path :: a | r } a 296 | _path = prop (Proxy :: Proxy "path") 297 | 298 | _patterns :: forall r a. Lens' { patterns :: a | r } a 299 | _patterns = prop (Proxy :: Proxy "patterns") 300 | 301 | _perms :: forall r a. Lens' { perms :: a | r } a 302 | _perms = prop (Proxy :: Proxy "perms") 303 | 304 | _position :: forall r a. Lens' { position :: a | r } a 305 | _position = prop (Proxy :: Proxy "position") 306 | 307 | _prec :: forall r a. Lens' { prec :: a | r } a 308 | _prec = prop (Proxy :: Proxy "prec") 309 | 310 | _qualified :: forall r a. Lens' { qualified :: a | r } a 311 | _qualified = prop (Proxy :: Proxy "qualified") 312 | 313 | _range :: forall r a. Lens' { range :: a | r } a 314 | _range = prop (Proxy :: Proxy "range") 315 | 316 | _rdev :: forall r a. Lens' { rdev :: a | r } a 317 | _rdev = prop (Proxy :: Proxy "rdev") 318 | 319 | _result :: forall r a. Lens' { result :: a | r } a 320 | _result = prop (Proxy :: Proxy "result") 321 | 322 | _ribbonRatio :: forall r a. Lens' { ribbonRatio :: a | r } a 323 | _ribbonRatio = prop (Proxy :: Proxy "ribbonRatio") 324 | 325 | _ribbonWidth :: forall r a. Lens' { ribbonWidth :: a | r } a 326 | _ribbonWidth = prop (Proxy :: Proxy "ribbonWidth") 327 | 328 | _separator :: forall r a. Lens' { separator :: a | r } a 329 | _separator = prop (Proxy :: Proxy "separator") 330 | 331 | _shell :: forall r a. Lens' { shell :: a | r } a 332 | _shell = prop (Proxy :: Proxy "shell") 333 | 334 | _size :: forall r a. Lens' { size :: a | r } a 335 | _size = prop (Proxy :: Proxy "size") 336 | 337 | _start :: forall r a. Lens' { start :: a | r } a 338 | _start = prop (Proxy :: Proxy "start") 339 | 340 | _statements :: forall r a. Lens' { statements :: a | r } a 341 | _statements = prop (Proxy :: Proxy "statements") 342 | 343 | _stderr :: forall r a. Lens' { stderr :: a | r } a 344 | _stderr = prop (Proxy :: Proxy "stderr") 345 | 346 | _stdio :: forall r a. Lens' { stdio :: a | r } a 347 | _stdio = prop (Proxy :: Proxy "stdio") 348 | 349 | _stdout :: forall r a. Lens' { stdout :: a | r } a 350 | _stdout = prop (Proxy :: Proxy "stdout") 351 | 352 | _sticky :: forall r a. Lens' { sticky :: a | r } a 353 | _sticky = prop (Proxy :: Proxy "sticky") 354 | 355 | _stream :: forall r a. Lens' { stream :: a | r } a 356 | _stream = prop (Proxy :: Proxy "stream") 357 | 358 | _super :: forall r a. Lens' { super :: a | r } a 359 | _super = prop (Proxy :: Proxy "super") 360 | 361 | _symbol :: forall r a. Lens' { symbol :: a | r } a 362 | _symbol = prop (Proxy :: Proxy "symbol") 363 | 364 | _syscall :: forall r a. Lens' { syscall :: a | r } a 365 | _syscall = prop (Proxy :: Proxy "syscall") 366 | 367 | _tail :: forall r a. Lens' { tail :: a | r } a 368 | _tail = prop (Proxy :: Proxy "tail") 369 | 370 | _then :: forall r a. Lens' { then :: a | r } a 371 | _then = prop (Proxy :: Proxy "then") 372 | 373 | _timeout :: forall r a. Lens' { timeout :: a | r } a 374 | _timeout = prop (Proxy :: Proxy "timeout") 375 | 376 | _title :: forall r a. Lens' { title :: a | r } a 377 | _title = prop (Proxy :: Proxy "title") 378 | 379 | _token :: forall r a. Lens' { token :: a | r } a 380 | _token = prop (Proxy :: Proxy "token") 381 | 382 | _trailingComments :: forall r a. Lens' { trailingComments :: a | r } a 383 | _trailingComments = prop (Proxy :: Proxy "trailingComments") 384 | 385 | _true :: forall r a. Lens' { true :: a | r } a 386 | _true = prop (Proxy :: Proxy "true") 387 | 388 | _typeArrowPlacement :: forall r a. Lens' { typeArrowPlacement :: a | r } a 389 | _typeArrowPlacement = prop (Proxy :: Proxy "typeArrowPlacement") 390 | 391 | _types :: forall r a. Lens' { types :: a | r } a 392 | _types = prop (Proxy :: Proxy "types") 393 | 394 | _uid :: forall r a. Lens' { uid :: a | r } a 395 | _uid = prop (Proxy :: Proxy "uid") 396 | 397 | _unicode :: forall r a. Lens' { unicode :: a | r } a 398 | _unicode = prop (Proxy :: Proxy "unicode") 399 | 400 | _upper :: forall r a. Lens' { upper :: a | r } a 401 | _upper = prop (Proxy :: Proxy "upper") 402 | 403 | _value :: forall r a. Lens' { value :: a | r } a 404 | _value = prop (Proxy :: Proxy "value") 405 | 406 | _vars :: forall r a. Lens' { vars :: a | r } a 407 | _vars = prop (Proxy :: Proxy "vars") 408 | 409 | _where :: forall r a. Lens' { where :: a | r } a 410 | _where = prop (Proxy :: Proxy "where") 411 | -------------------------------------------------------------------------------- /lenses/Tidy/Codegen/Class/Lens.purs: -------------------------------------------------------------------------------- 1 | module Tidy.Codegen.Class.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens.Iso (Iso') 6 | import Prelude (identity) 7 | import PureScript.CST.Types (Comment, LineFeed) 8 | import Tidy.Codegen.Class (LeadingComments, TrailingComments) 9 | 10 | _LeadingComments 11 | :: forall r. Iso' (LeadingComments r) (leadingComments :: Array (Comment LineFeed) | r) 12 | _LeadingComments = identity 13 | 14 | _TrailingComments 15 | :: forall trl r. Iso' (TrailingComments trl r) (trailingComments :: Array (Comment trl) | r) 16 | _TrailingComments = identity 17 | -------------------------------------------------------------------------------- /lenses/Tidy/Codegen/Lens.purs: -------------------------------------------------------------------------------- 1 | module Tidy.Codegen.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lazy (Lazy) 6 | import Data.Lens.Iso (Iso') 7 | import Prelude (identity) 8 | import Tidy (ImportWrapOption, TypeArrowOption, UnicodeOption) 9 | import Tidy.Codegen (PrintOptions) 10 | import Tidy.Precedence (PrecedenceMap) 11 | 12 | _PrintOptions :: Iso' PrintOptions 13 | { importWrap :: ImportWrapOption 14 | , indentUnit :: String 15 | , indentWidth :: Int 16 | , operators :: Lazy PrecedenceMap 17 | , pageWidth :: Int 18 | , ribbonRatio :: Number 19 | , typeArrowPlacement :: TypeArrowOption 20 | , unicode :: UnicodeOption 21 | } 22 | _PrintOptions = identity 23 | -------------------------------------------------------------------------------- /lenses/Tidy/Codegen/Monad/Lens.purs: -------------------------------------------------------------------------------- 1 | module Tidy.Codegen.Monad.Lens where 2 | 3 | import Prelude 4 | 5 | import Control.Monad.Free (Free) 6 | import Data.Either (Either(..)) 7 | import Data.Identity (Identity) 8 | import Data.Lens (Lens') 9 | import Data.Lens.Iso (Iso', iso) 10 | import Data.Lens.Prism (Prism', prism) 11 | import Data.List (List) 12 | import Data.Map (Map) 13 | import Data.Set (Set) 14 | import Data.Tuple (Tuple(..)) 15 | import Prelude (identity) 16 | import PureScript.CST.Types (Declaration, Ident, ModuleName, Proper, QualifiedName) 17 | import Tidy.Codegen.Monad (Codegen, CodegenState, CodegenT, CodegenExport(..), CodegenImport(..), ImportName(..)) 18 | import Tidy.Codegen.Types (SymbolName) 19 | 20 | _CodegenExportType :: Prism' CodegenExport (Tuple Boolean Proper) 21 | _CodegenExportType = prism (\(Tuple a b) -> CodegenExportType a b) case _ of 22 | CodegenExportType a b -> Right (Tuple a b) 23 | other -> Left other 24 | 25 | _CodegenExportTypeOp :: Prism' CodegenExport SymbolName 26 | _CodegenExportTypeOp = prism CodegenExportTypeOp case _ of 27 | CodegenExportTypeOp a -> Right a 28 | other -> Left other 29 | 30 | _CodegenExportClass :: Prism' CodegenExport Proper 31 | _CodegenExportClass = prism CodegenExportClass case _ of 32 | CodegenExportClass a -> Right a 33 | other -> Left other 34 | 35 | _CodegenExportValue :: Prism' CodegenExport Ident 36 | _CodegenExportValue = prism CodegenExportValue case _ of 37 | CodegenExportValue a -> Right a 38 | other -> Left other 39 | 40 | _CodegenExportOp :: Prism' CodegenExport SymbolName 41 | _CodegenExportOp = prism CodegenExportOp case _ of 42 | CodegenExportOp a -> Right a 43 | other -> Left other 44 | 45 | _CodegenExportModule :: Prism' CodegenExport ModuleName 46 | _CodegenExportModule = prism CodegenExportModule case _ of 47 | CodegenExportModule a -> Right a 48 | other -> Left other 49 | 50 | _CodegenImportType :: Prism' CodegenImport (Tuple Boolean Proper) 51 | _CodegenImportType = prism (\(Tuple a b) -> CodegenImportType a b) case _ of 52 | CodegenImportType a b -> Right (Tuple a b) 53 | other -> Left other 54 | 55 | _CodegenImportTypeOp :: Prism' CodegenImport SymbolName 56 | _CodegenImportTypeOp = prism CodegenImportTypeOp case _ of 57 | CodegenImportTypeOp a -> Right a 58 | other -> Left other 59 | 60 | _CodegenImportClass :: Prism' CodegenImport Proper 61 | _CodegenImportClass = prism CodegenImportClass case _ of 62 | CodegenImportClass a -> Right a 63 | other -> Left other 64 | 65 | _CodegenImportValue :: Prism' CodegenImport Ident 66 | _CodegenImportValue = prism CodegenImportValue case _ of 67 | CodegenImportValue a -> Right a 68 | other -> Left other 69 | 70 | _CodegenImportOp :: Prism' CodegenImport SymbolName 71 | _CodegenImportOp = prism CodegenImportOp case _ of 72 | CodegenImportOp a -> Right a 73 | other -> Left other 74 | 75 | _CodegenState 76 | :: forall e 77 | . Iso' (CodegenState e) 78 | { exports :: Set CodegenExport 79 | , importsOpen :: Set ModuleName 80 | , importsHiding :: Map ModuleName (Set CodegenImport) 81 | , importsHidingQualified :: Map ModuleName (Map ModuleName (Set CodegenImport)) 82 | , importsFrom :: Map ModuleName (Set (CodegenImport)) 83 | , importsQualified :: Map ModuleName (Set ModuleName) 84 | , declarations :: List (Declaration e) 85 | } 86 | _CodegenState = identity 87 | 88 | _Codegen :: forall e. Iso' (Codegen e) (CodegenT e (Free Identity)) 89 | _Codegen = identity 90 | 91 | _ImportName :: forall name. Lens' (ImportName name) (Tuple CodegenImport (QualifiedName name)) 92 | _ImportName = iso (\(ImportName a b) -> Tuple a b) \(Tuple a b) -> ImportName a b 93 | -------------------------------------------------------------------------------- /lenses/Tidy/Codegen/Types/Lens.purs: -------------------------------------------------------------------------------- 1 | module Tidy.Codegen.Types.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Array.NonEmpty (NonEmptyArray) 6 | import Data.Lens (Lens') 7 | import Data.Lens.Iso (Iso', iso) 8 | import Data.Lens.Iso.Newtype (_Newtype) 9 | import Data.Maybe (Maybe) 10 | import Data.Tuple (Tuple(..)) 11 | import Prelude (identity) 12 | import PureScript.CST.Types (Ident, Labeled, ModuleName, Name, PatternGuard, Where) 13 | import PureScript.CST.Types as CST 14 | import Tidy.Codegen.Types (ClassMember, SourceString, SymbolName, GuardedBranch(..), Qualified(..)) 15 | 16 | _SymbolName :: Lens' SymbolName String 17 | _SymbolName = _Newtype 18 | 19 | _Qualified :: forall a. Lens' (Qualified a) (Tuple (Maybe ModuleName) a) 20 | _Qualified = iso (\(Qualified a b) -> Tuple a b) \(Tuple a b) -> Qualified a b 21 | 22 | _GuardedBranch 23 | :: forall e. Lens' (GuardedBranch e) (Tuple (NonEmptyArray (PatternGuard e)) (Where e)) 24 | _GuardedBranch = iso (\(GuardedBranch a b) -> Tuple a b) \(Tuple a b) -> GuardedBranch a b 25 | 26 | _ClassMember :: forall e. Iso' (ClassMember e) (Labeled (Name Ident) (CST.Type e)) 27 | _ClassMember = identity 28 | 29 | _SourceString :: Lens' SourceString String 30 | _SourceString = _Newtype 31 | -------------------------------------------------------------------------------- /lenses/Tidy/Doc/Lens.purs: -------------------------------------------------------------------------------- 1 | module Tidy.Doc.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Prism (Prism', prism) 5 | import Prelude (Unit, const, unit) 6 | import Tidy.Doc (ForceBreak(..)) 7 | 8 | _ForceNone :: Prism' ForceBreak Unit 9 | _ForceNone = prism (const ForceNone) case _ of 10 | ForceNone -> Right unit 11 | other -> Left other 12 | 13 | _ForceSpace :: Prism' ForceBreak Unit 14 | _ForceSpace = prism (const ForceSpace) case _ of 15 | ForceSpace -> Right unit 16 | other -> Left other 17 | 18 | _ForceBreak :: Prism' ForceBreak Unit 19 | _ForceBreak = prism (const ForceBreak) case _ of 20 | ForceBreak -> Right unit 21 | other -> Left other 22 | -------------------------------------------------------------------------------- /lenses/Tidy/Hang/Lens.purs: -------------------------------------------------------------------------------- 1 | module Tidy.Hang.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso (iso) 7 | import Tidy.Doc (FormatDoc) 8 | import Tidy.Hang (HangingDoc, HangingOp(..)) 9 | 10 | _HangingOp 11 | :: forall a. Lens' (HangingOp a) { arg1 :: Int, arg2 :: (FormatDoc a), arg3 :: (HangingDoc a) } 12 | _HangingOp = iso (\(HangingOp arg1 arg2 arg3) -> { arg1: arg1, arg2: arg2, arg3: arg3 }) 13 | \{ arg1, arg2, arg3 } -> HangingOp arg1 arg2 arg3 14 | -------------------------------------------------------------------------------- /lenses/Tidy/Lens.purs: -------------------------------------------------------------------------------- 1 | module Tidy.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Iso (Iso') 5 | import Data.Lens.Prism (Prism', prism) 6 | import Prelude (Unit, const, identity, unit) 7 | import Tidy (Format, FormatOptions, ImportWrapOption(..), TypeArrowOption(..)) 8 | import Tidy.Doc (FormatDoc) 9 | import Tidy.Precedence (PrecedenceMap) 10 | import Tidy.Token (UnicodeOption) 11 | 12 | _TypeArrowFirst :: Prism' TypeArrowOption Unit 13 | _TypeArrowFirst = prism (const TypeArrowFirst) case _ of 14 | TypeArrowFirst -> Right unit 15 | other -> Left other 16 | 17 | _TypeArrowLast :: Prism' TypeArrowOption Unit 18 | _TypeArrowLast = prism (const TypeArrowLast) case _ of 19 | TypeArrowLast -> Right unit 20 | other -> Left other 21 | 22 | _ImportWrapSource :: Prism' ImportWrapOption Unit 23 | _ImportWrapSource = prism (const ImportWrapSource) case _ of 24 | ImportWrapSource -> Right unit 25 | other -> Left other 26 | 27 | _ImportWrapAuto :: Prism' ImportWrapOption Unit 28 | _ImportWrapAuto = prism (const ImportWrapAuto) case _ of 29 | ImportWrapAuto -> Right unit 30 | other -> Left other 31 | 32 | _FormatOptions 33 | :: forall e a 34 | . Iso' (FormatOptions e a) 35 | { formatError :: e -> FormatDoc a 36 | , unicode :: UnicodeOption 37 | , typeArrowPlacement :: TypeArrowOption 38 | , operators :: PrecedenceMap 39 | , importWrap :: ImportWrapOption 40 | } 41 | _FormatOptions = identity 42 | 43 | _Format :: forall f e a. Iso' (Format f e a) (FormatOptions e a -> f -> FormatDoc a) 44 | _Format = identity 45 | -------------------------------------------------------------------------------- /lenses/Tidy/Precedence/Lens.purs: -------------------------------------------------------------------------------- 1 | module Tidy.Precedence.Lens where 2 | 3 | import Prelude 4 | 5 | import Data.Array.NonEmpty (NonEmptyArray) 6 | import Data.Either (Either(..)) 7 | import Data.Lens (Lens') 8 | import Data.Lens.Iso (Iso', iso) 9 | import Data.Lens.Prism (Prism', prism) 10 | import Data.Map (Map) 11 | import Data.Maybe (Maybe) 12 | import Data.Tuple (Tuple) 13 | import Prelude (Unit, const, identity, unit) 14 | import PureScript.CST.Types (ModuleName, Operator) 15 | import Tidy.Precedence (OperatorChain, Precedence, PrecedenceMap, OperatorNamespace(..), OperatorTree(..), QualifiedOperator(..)) 16 | 17 | _OperatorType :: Prism' OperatorNamespace Unit 18 | _OperatorType = prism (const OperatorType) case _ of 19 | OperatorType -> Right unit 20 | other -> Left other 21 | 22 | _OperatorValue :: Prism' OperatorNamespace Unit 23 | _OperatorValue = prism (const OperatorValue) case _ of 24 | OperatorValue -> Right unit 25 | other -> Left other 26 | 27 | _QualifiedOperator :: Lens' QualifiedOperator 28 | { arg1 :: (Maybe ModuleName), arg2 :: OperatorNamespace, arg3 :: Operator } 29 | _QualifiedOperator = iso 30 | (\(QualifiedOperator arg1 arg2 arg3) -> { arg1: arg1, arg2: arg2, arg3: arg3 }) 31 | \{ arg1, arg2, arg3 } -> QualifiedOperator arg1 arg2 arg3 32 | 33 | _Precedence :: Iso' Precedence Int 34 | _Precedence = identity 35 | 36 | _PrecedenceMap :: Iso' PrecedenceMap 37 | (Map (Maybe ModuleName) (Map (Tuple OperatorNamespace Operator) Precedence)) 38 | _PrecedenceMap = identity 39 | 40 | _OpList 41 | :: forall op a 42 | . Prism' (OperatorTree op a) 43 | { arg1 :: (OperatorTree op a), arg2 :: Precedence, arg3 :: (OperatorChain op a) } 44 | _OpList = prism (\{ arg1, arg2, arg3 } -> OpList arg1 arg2 arg3) case _ of 45 | OpList arg1 arg2 arg3 -> Right { arg1: arg1, arg2: arg2, arg3: arg3 } 46 | other -> Left other 47 | 48 | _OpPure :: forall op a. Prism' (OperatorTree op a) a 49 | _OpPure = prism OpPure case _ of 50 | OpPure a -> Right a 51 | other -> Left other 52 | 53 | _OperatorChain 54 | :: forall op a. Iso' (OperatorChain op a) (NonEmptyArray (Tuple op (OperatorTree op a))) 55 | _OperatorChain = identity 56 | -------------------------------------------------------------------------------- /lenses/Tidy/Token/Lens.purs: -------------------------------------------------------------------------------- 1 | module Tidy.Token.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens.Prism (Prism', prism) 5 | import Prelude (Unit, const, unit) 6 | import Tidy.Token (UnicodeOption(..)) 7 | 8 | _UnicodeSource :: Prism' UnicodeOption Unit 9 | _UnicodeSource = prism (const UnicodeSource) case _ of 10 | UnicodeSource -> Right unit 11 | other -> Left other 12 | 13 | _UnicodeAlways :: Prism' UnicodeOption Unit 14 | _UnicodeAlways = prism (const UnicodeAlways) case _ of 15 | UnicodeAlways -> Right unit 16 | other -> Left other 17 | 18 | _UnicodeNever :: Prism' UnicodeOption Unit 19 | _UnicodeNever = prism (const UnicodeNever) case _ of 20 | UnicodeNever -> Right unit 21 | other -> Left other 22 | -------------------------------------------------------------------------------- /lenses/Type/Data/Boolean/Lens.purs: -------------------------------------------------------------------------------- 1 | module Type.Data.Boolean.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Prelude (Unit, const, unit) 6 | import Type.Data.Boolean (BProxy(..)) 7 | 8 | _BProxy :: forall bool. Lens' (BProxy bool) Unit 9 | _BProxy = iso (const unit) (const BProxy) 10 | -------------------------------------------------------------------------------- /lenses/Type/Data/Ordering/Lens.purs: -------------------------------------------------------------------------------- 1 | module Type.Data.Ordering.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Prelude (Unit, const, unit) 6 | import Type.Data.Ordering (OProxy(..)) 7 | 8 | _OProxy :: forall ordering. Lens' (OProxy ordering) Unit 9 | _OProxy = iso (const unit) (const OProxy) 10 | -------------------------------------------------------------------------------- /lenses/Type/Data/Row/Lens.purs: -------------------------------------------------------------------------------- 1 | module Type.Data.Row.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Prelude (Unit, const, unit) 6 | import Type.Data.Row (RProxy(..)) 7 | 8 | _RProxy :: forall row. Lens' (RProxy row) Unit 9 | _RProxy = iso (const unit) (const RProxy) 10 | -------------------------------------------------------------------------------- /lenses/Type/Data/RowList/Lens.purs: -------------------------------------------------------------------------------- 1 | module Type.Data.RowList.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Prelude (Unit, const, unit) 6 | import Type.Data.RowList (RLProxy(..)) 7 | 8 | _RLProxy :: forall rowlist. Lens' (RLProxy rowlist) Unit 9 | _RLProxy = iso (const unit) (const RLProxy) 10 | -------------------------------------------------------------------------------- /lenses/Type/Function/Lens.purs: -------------------------------------------------------------------------------- 1 | module Type.Function.Lens where 2 | 3 | import Data.Lens.Iso (Iso') 4 | import Prelude (identity) 5 | import Type.Function (APPLY, FLIP) 6 | 7 | _APPLY :: forall f a. Iso' (APPLY f a) (f a) 8 | _APPLY = identity 9 | 10 | _FLIP :: forall a f. Iso' (FLIP a f) (f a) 11 | _FLIP = identity 12 | -------------------------------------------------------------------------------- /lenses/Type/Proxy/Lens.purs: -------------------------------------------------------------------------------- 1 | module Type.Proxy.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Prelude (Unit, const, unit) 6 | import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..)) 7 | 8 | _Proxy :: forall a. Lens' (Proxy a) Unit 9 | _Proxy = iso (const unit) (const Proxy) 10 | 11 | _Proxy2 :: forall f. Lens' (Proxy2 f) Unit 12 | _Proxy2 = iso (const unit) (const Proxy2) 13 | 14 | _Proxy3 :: forall a. Lens' (Proxy3 a) Unit 15 | _Proxy3 = iso (const unit) (const Proxy3) 16 | -------------------------------------------------------------------------------- /lenses/Type/Row/Lens.purs: -------------------------------------------------------------------------------- 1 | module Type.Row.Lens where 2 | 3 | import Data.Lens.Iso (Iso') 4 | import Prelude (identity) 5 | import Type.Row (RowApply) 6 | 7 | _RowApply :: forall f a. Iso' (RowApply f a) (f a) 8 | _RowApply = identity 9 | -------------------------------------------------------------------------------- /packages.dhall: -------------------------------------------------------------------------------- 1 | let upstream = 2 | https://github.com/purescript/package-sets/releases/download/psc-0.14.5-20211116/packages.dhall sha256:7ba810597a275e43c83411d2ab0d4b3c54d0b551436f4b1632e9ff3eb62e327a 3 | 4 | in upstream 5 | with tidy-codegen = 6 | { dependencies = 7 | [ "aff" 8 | , "ansi" 9 | , "arrays" 10 | , "avar" 11 | , "bifunctors" 12 | , "console" 13 | , "control" 14 | , "dodo-printer" 15 | , "effect" 16 | , "either" 17 | , "enums" 18 | , "exceptions" 19 | , "filterable" 20 | , "foldable-traversable" 21 | , "free" 22 | , "identity" 23 | , "integers" 24 | , "language-cst-parser" 25 | , "lazy" 26 | , "lists" 27 | , "maybe" 28 | , "newtype" 29 | , "node-buffer" 30 | , "node-child-process" 31 | , "node-fs-aff" 32 | , "node-path" 33 | , "node-process" 34 | , "node-streams" 35 | , "ordered-collections" 36 | , "parallel" 37 | , "partial" 38 | , "posix-types" 39 | , "prelude" 40 | , "record" 41 | , "safe-coerce" 42 | , "strings" 43 | , "tidy" 44 | , "transformers" 45 | , "tuples" 46 | , "type-equality" 47 | , "unicode" 48 | ] 49 | , repo = "https://github.com/JordanMartinez/purescript-tidy-codegen.git" 50 | , version = "include-all-fixes" 51 | } 52 | with dodo-printer = 53 | { dependencies = 54 | [ "ansi", "foldable-traversable", "lists", "maybe", "strings" ] 55 | , repo = "https://github.com/natefaubion/purescript-dodo-printer.git" 56 | , version = "v2.1.0" 57 | } 58 | with language-cst-parser = 59 | { dependencies = 60 | [ "arrays" 61 | , "const" 62 | , "effect" 63 | , "either" 64 | , "foldable-traversable" 65 | , "free" 66 | , "functors" 67 | , "maybe" 68 | , "numbers" 69 | , "ordered-collections" 70 | , "strings" 71 | , "transformers" 72 | , "tuples" 73 | , "typelevel-prelude" 74 | ] 75 | , repo = 76 | "https://github.com/natefaubion/purescript-language-cst-parser.git" 77 | , version = "v0.9.1" 78 | } 79 | with tidy = 80 | { dependencies = 81 | [ "arrays" 82 | , "dodo-printer" 83 | , "foldable-traversable" 84 | , "lists" 85 | , "maybe" 86 | , "ordered-collections" 87 | , "partial" 88 | , "prelude" 89 | , "language-cst-parser" 90 | , "strings" 91 | , "tuples" 92 | ] 93 | , repo = 94 | "https://github.com/natefaubion/purescript-tidy.git" 95 | , version = "v0.5.3" 96 | } 97 | with argparse-basic = 98 | { dependencies = 99 | [ "arrays" 100 | , "console" 101 | , "debug" 102 | , "effect" 103 | , "either" 104 | , "foldable-traversable" 105 | , "free" 106 | , "lists" 107 | , "maybe" 108 | , "node-process" 109 | , "record" 110 | , "strings" 111 | , "transformers" 112 | ] 113 | , repo = "https://github.com/natefaubion/purescript-argparse-basic.git" 114 | , version = "v1.0.0" 115 | } 116 | with node-glob-basic = 117 | { dependencies = 118 | [ "aff" 119 | , "console" 120 | , "effect" 121 | , "either" 122 | , "foldable-traversable" 123 | , "lists" 124 | , "maybe" 125 | , "node-fs" 126 | , "node-fs-aff" 127 | , "node-path" 128 | , "node-process" 129 | , "ordered-collections" 130 | , "parallel" 131 | , "prelude" 132 | , "refs" 133 | , "strings" 134 | , "tuples" 135 | ] 136 | , repo = "https://github.com/natefaubion/purescript-node-glob-basic.git" 137 | , version = "v1.2.2" 138 | } 139 | -------------------------------------------------------------------------------- /regen-lenses.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | rm -rf lenses 4 | 5 | ./tidy-mklens.js \ 6 | --output-dir lenses \ 7 | --gen-type-alias-isos \ 8 | --label-prefix-none \ 9 | --global-record-lens-module Dependencies.RecordLens \ 10 | .spago/*/*/src/**/*.purs:4 -------------------------------------------------------------------------------- /regen-snapshots.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | rm \ 4 | snapshots/CheckOpenImports/Reimport/Lens.purs \ 5 | snapshots/CheckOpenImports/Remove/Lens.purs \ 6 | snapshots/CheckOpenImports/RemoveHiding/Lens.purs \ 7 | snapshots/PrimaryExample/Lens.purs \ 8 | snapshots/UseAbcLabelStyle/Lens.purs \ 9 | snapshots/UseArgLabelStyle/Lens.purs \ 10 | snapshots/UseGlobalPropFile/GlobalRecordLens.purs \ 11 | snapshots/UseLocalProps/Module1/Lens.purs \ 12 | snapshots/UseLocalProps/Module2/Lens.purs \ 13 | snapshots/UseTypeAliases/Lens.purs \ 14 | snapshots/UseLabelPrefix/Lens.purs \ 15 | snapshots/UseNoLabelPrefix/Lens.purs 16 | 17 | ./tidy-mklens.js --label-style-arg --output-dir snapshots snapshots/UseArgLabelStyle.purs 18 | 19 | ./tidy-mklens.js --label-style-abc --output-dir snapshots snapshots/UseAbcLabelStyle.purs 20 | 21 | ./tidy-mklens.js --gen-type-alias-isos --output-dir snapshots snapshots/UseTypeAliases.purs 22 | 23 | ./tidy-mklens.js --label-prefix "prop" --output-dir snapshots snapshots/UseLabelPrefix.purs 24 | 25 | ./tidy-mklens.js --label-prefix-none --output-dir snapshots snapshots/UseNoLabelPrefix.purs 26 | 27 | ./tidy-mklens.js --output-dir snapshots snapshots/UseLocalProps/ 28 | 29 | ./tidy-mklens.js \ 30 | --output-dir snapshots \ 31 | --global-record-lens-module UseGlobalPropFile.GlobalRecordLens \ 32 | snapshots/UseGlobalPropFile 33 | 34 | ./tidy-mklens.js --gen-type-alias-isos --output-dir snapshots snapshots/PrimaryExample.purs 35 | 36 | ./tidy-mklens.js --output-dir snapshots snapshots/CheckOpenImports -------------------------------------------------------------------------------- /snapshots.dhall: -------------------------------------------------------------------------------- 1 | { name = "snapshots" 2 | , dependencies = 3 | [ "either" 4 | , "newtype" 5 | , "prelude" 6 | , "profunctor-lenses" 7 | , "psci-support" 8 | , "tuples" 9 | ] 10 | , packages = ./packages.dhall 11 | , sources = [ "snapshots/**/*.purs" ] 12 | } 13 | -------------------------------------------------------------------------------- /snapshots/CheckOpenImports/Reimport.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.CheckOpenImports.Reimport where 2 | 3 | -- This open import should be re-imported 4 | -- since the 'Ordering' type wasn't found. 5 | import Snapshots.Imports.OpenImportNameClashes 6 | 7 | data One = One 8 | data Two = Two 9 | 10 | data Foo = Foo One Two Ordering 11 | -------------------------------------------------------------------------------- /snapshots/CheckOpenImports/Reimport/Lens.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.CheckOpenImports.Reimport.Lens where 2 | 3 | import Snapshots.Imports.OpenImportNameClashes 4 | 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso (iso) 7 | import Data.Lens.Record (prop) 8 | import Prelude (Unit, const, unit) 9 | import Snapshots.CheckOpenImports.Reimport (Foo(..), One(..), Two(..)) 10 | import Type.Proxy (Proxy(..)) 11 | 12 | _One :: Lens' One Unit 13 | _One = iso (const unit) (const One) 14 | 15 | _Two :: Lens' Two Unit 16 | _Two = iso (const unit) (const Two) 17 | 18 | _Foo :: Lens' Foo { arg1 :: One, arg2 :: Two, arg3 :: Ordering } 19 | _Foo = iso (\(Foo arg1 arg2 arg3) -> { arg1: arg1, arg2: arg2, arg3: arg3 }) 20 | \{ arg1, arg2, arg3 } -> Foo arg1 arg2 arg3 21 | 22 | _propArg1 :: forall r a. Lens' { arg1 :: a | r } a 23 | _propArg1 = prop (Proxy :: Proxy "arg1") 24 | 25 | _propArg2 :: forall r a. Lens' { arg2 :: a | r } a 26 | _propArg2 = prop (Proxy :: Proxy "arg2") 27 | 28 | _propArg3 :: forall r a. Lens' { arg3 :: a | r } a 29 | _propArg3 = prop (Proxy :: Proxy "arg3") 30 | -------------------------------------------------------------------------------- /snapshots/CheckOpenImports/Remove.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.CheckOpenImports.Remove where 2 | 3 | -- This open import should be removed 4 | -- since all referenced types are findable. 5 | import Prelude 6 | 7 | data One = One 8 | data Two = Two 9 | 10 | data Foo = Foo One Two 11 | -------------------------------------------------------------------------------- /snapshots/CheckOpenImports/Remove/Lens.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.CheckOpenImports.Remove.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Data.Lens.Record (prop) 6 | import Data.Tuple (Tuple(..)) 7 | import Prelude (Unit, const, unit) 8 | import Snapshots.CheckOpenImports.Remove (Foo(..), One(..), Two(..)) 9 | import Type.Proxy (Proxy(..)) 10 | 11 | _One :: Lens' One Unit 12 | _One = iso (const unit) (const One) 13 | 14 | _Two :: Lens' Two Unit 15 | _Two = iso (const unit) (const Two) 16 | 17 | _Foo :: Lens' Foo (Tuple One Two) 18 | _Foo = iso (\(Foo a b) -> Tuple a b) \(Tuple a b) -> Foo a b 19 | -------------------------------------------------------------------------------- /snapshots/CheckOpenImports/RemoveHiding.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.CheckOpenImports.RemoveHiding where 2 | 3 | -- This open import should be re-imported 4 | -- but without the 'NameClash' member hidden 5 | -- since it doesn't clash with any other types. 6 | -- However, this may significantly slow down the implementation, 7 | -- so I'm not handling this case yet because of how rare it likely is. 8 | import Snapshots.Imports.OpenImportNameClashes hiding (NameClash) 9 | 10 | data One = One 11 | data Two = Two 12 | 13 | data Foo = Foo One Two NameIsFine 14 | -------------------------------------------------------------------------------- /snapshots/CheckOpenImports/RemoveHiding/Lens.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.CheckOpenImports.RemoveHiding.Lens where 2 | 3 | import Snapshots.Imports.OpenImportNameClashes hiding (NameClash) 4 | 5 | import Data.Lens (Lens') 6 | import Data.Lens.Iso (iso) 7 | import Data.Lens.Record (prop) 8 | import Prelude (Unit, const, unit) 9 | import Snapshots.CheckOpenImports.RemoveHiding (Foo(..), One(..), Two(..)) 10 | import Type.Proxy (Proxy(..)) 11 | 12 | _One :: Lens' One Unit 13 | _One = iso (const unit) (const One) 14 | 15 | _Two :: Lens' Two Unit 16 | _Two = iso (const unit) (const Two) 17 | 18 | _Foo :: Lens' Foo { arg1 :: One, arg2 :: Two, arg3 :: NameIsFine } 19 | _Foo = iso (\(Foo arg1 arg2 arg3) -> { arg1: arg1, arg2: arg2, arg3: arg3 }) 20 | \{ arg1, arg2, arg3 } -> Foo arg1 arg2 arg3 21 | 22 | _propArg1 :: forall r a. Lens' { arg1 :: a | r } a 23 | _propArg1 = prop (Proxy :: Proxy "arg1") 24 | 25 | _propArg2 :: forall r a. Lens' { arg2 :: a | r } a 26 | _propArg2 = prop (Proxy :: Proxy "arg2") 27 | 28 | _propArg3 :: forall r a. Lens' { arg3 :: a | r } a 29 | _propArg3 = prop (Proxy :: Proxy "arg3") 30 | -------------------------------------------------------------------------------- /snapshots/Imports/ImportedExplicitTypesNoModuleAlias.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.Imports.ImportedExplicitTypesNoModuleAlias where 2 | 3 | data MyData a b c = MyData a b c 4 | 5 | newtype MyNewtype :: Type -> Type -> Type -> Type 6 | newtype MyNewtype a b c = MyNewtype String 7 | 8 | type MyAlias a = Array a 9 | -------------------------------------------------------------------------------- /snapshots/Imports/ImportedExplicitTypesWithModuleAlias.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.Imports.ImportedExplicitTypesWithModuleAlias where 2 | 3 | data MyData a b c = MyData a b c 4 | 5 | newtype MyNewtype :: Type -> Type -> Type -> Type 6 | newtype MyNewtype a b c = MyNewtype String 7 | 8 | type MyAlias a = Array a 9 | -------------------------------------------------------------------------------- /snapshots/Imports/ModuleAliasOnly.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.Imports.ModuleAliasOnly where 2 | 3 | data MyData a b c = MyData a b c 4 | 5 | newtype MyNewtype :: Type -> Type -> Type -> Type 6 | newtype MyNewtype a b c = MyNewtype String 7 | 8 | type MyAlias a = Array a 9 | -------------------------------------------------------------------------------- /snapshots/Imports/OpenImportNameClashes.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.Imports.OpenImportNameClashes where 2 | 3 | data NameClash = NameClash 4 | 5 | data NameIsFine = NameIsFine 6 | 7 | data Ordering = Ordering 8 | -------------------------------------------------------------------------------- /snapshots/Imports/SharedModuleAlias.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.Imports.SharedModuleAlias where 2 | 3 | data SharedMyData a b c = MyData a b c 4 | 5 | newtype SharedMyNewtype :: Type -> Type -> Type -> Type 6 | newtype SharedMyNewtype a b c = SharedMyNewtype String 7 | 8 | type SharedMyAlias a = Array a 9 | -------------------------------------------------------------------------------- /snapshots/PrimaryExample.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.PrimaryExample 2 | ( AliasDefinedInSourceFile 3 | , DataDefinedInSourceFile(..) 4 | , Data_NoTyVars_Args0(..) 5 | , Data_NoTyVars_Args1(..) 6 | , Data_NoTyVars_Args2(..) 7 | , Data_NoTyVars_Args3(..) 8 | , Data_NoTyVars_Sum_Args0(..) 9 | , Data_NoTyVars_Sum_Args1(..) 10 | , Data_NoTyVars_Sum_Args2(..) 11 | , Data_NoTyVars_Sum_Args3(..) 12 | , Data_Product_ImportedTypesAreReimported(..) 13 | , Data_Sum_ImportedTypesAreReimported(..) 14 | , Data_TyVars_Args0(..) 15 | , Data_TyVars_Args1(..) 16 | , Data_TyVars_Args2(..) 17 | , Data_TyVars_Args3(..) 18 | , Data_TyVars_Sum_Args0(..) 19 | , Data_TyVars_Sum_Args1(..) 20 | , Data_TyVars_Sum_Args2(..) 21 | , Data_TyVars_Sum_Args3(..) 22 | , Data_TypeExported_CtorExported_Product_All(..) 23 | , Data_TypeExported_CtorExported_Sum_All(..) 24 | -- , Data_TypeNotExported(..) 25 | , Data_TypeOnlyExported 26 | , Data_Wrapping_Record(..) 27 | , EnsureSharedImportIsUsed(..) 28 | , FfiTypeDefinedInSourceFile 29 | , KindedTyVars(..) 30 | , NewtypeDefinedInSourceFile(..) 31 | , Newtype_TypeExported_CtorExported_All(..) 32 | , Newtype_TypeExported_CtorExported_ByName(Newtype_TypeExported_CtorExported_ByName) 33 | , Newtype_TypeExported_CtorExported_NoDerivedNewtypeInstance(..) 34 | -- , Newtype_TypeNotExported(..) 35 | , Newtype_TypeOnlyExported 36 | , NewtypedRecord(..) 37 | , NewtypedRecordWithTyVars(..) 38 | , NewtypedType(..) 39 | , Record_ImportedTypesAreReimported(..) 40 | , TypeAlias_Record 41 | , TypeAlias_Type 42 | , TypeAlias_TypeExported 43 | -- , TypeAlias_TypeNotExported 44 | , usePrelude 45 | ) 46 | where 47 | 48 | import Prelude 49 | import Prim hiding (Char) 50 | import Prim.Row hiding (class Cons) 51 | 52 | import Data.Newtype (class Newtype) 53 | import Prim.Boolean hiding (True) as PB 54 | import Snapshots.Imports.ImportedExplicitTypesNoModuleAlias (MyAlias, MyData, MyNewtype) 55 | import Snapshots.Imports.ImportedExplicitTypesWithModuleAlias (MyData, MyNewtype, MyAlias) as Shared 56 | import Snapshots.Imports.ModuleAliasOnly as Q 57 | import Snapshots.Imports.SharedModuleAlias as Shared 58 | import Snapshots.UseKindedTyVars (KindedTyVars(..)) 59 | 60 | data Data_NoTyVars_Args0 = Data_NoTyVars_Args0 61 | 62 | data Data_NoTyVars_Args1 = Data_NoTyVars_Args1 Int 63 | 64 | data Data_NoTyVars_Args2 = Data_NoTyVars_Args2 Int String 65 | 66 | data Data_NoTyVars_Args3 = Data_NoTyVars_Args3 Int String Boolean 67 | 68 | data Data_TyVars_Args0 :: Type -> Type -> Type -> Type -> Type 69 | data Data_TyVars_Args0 a b c d = Data_TyVars_Args0 70 | 71 | data Data_TyVars_Args1 :: Type -> Type -> Type -> Type -> Type 72 | data Data_TyVars_Args1 a b c d = Data_TyVars_Args1 a 73 | 74 | data Data_TyVars_Args2 :: Type -> Type -> Type -> Type -> Type 75 | data Data_TyVars_Args2 a b c d = Data_TyVars_Args2 a b 76 | 77 | data Data_TyVars_Args3 :: Type -> Type -> Type -> Type -> Type 78 | data Data_TyVars_Args3 a b c d = Data_TyVars_Args3 a b c 79 | 80 | data Data_NoTyVars_Sum_Args0 81 | = Data_NoTyVars_Sum_Args0 82 | | Data_NoTyVars_Sum_Args0_Ignored 83 | 84 | data Data_NoTyVars_Sum_Args1 85 | = Data_NoTyVars_Sum_Args1 Int 86 | | Data_NoTyVars_Sum_Args1_Ignored 87 | 88 | data Data_NoTyVars_Sum_Args2 89 | = Data_NoTyVars_Sum_Args2 Int Int 90 | | Data_NoTyVars_Sum_Args2_Ignored 91 | 92 | data Data_NoTyVars_Sum_Args3 93 | = Data_NoTyVars_Sum_Args3 Int Int Int 94 | | Data_NoTyVars_Sum_Args3_Ignored 95 | 96 | data Data_TyVars_Sum_Args0 :: Type -> Type -> Type -> Type -> Type 97 | data Data_TyVars_Sum_Args0 a b c d 98 | = Data_TyVars_Sum_Args0 99 | | Data_TyVars_Sum_Args0_Ignored 100 | 101 | data Data_TyVars_Sum_Args1 :: Type -> Type -> Type -> Type -> Type 102 | data Data_TyVars_Sum_Args1 a b c d 103 | = Data_TyVars_Sum_Args1 a 104 | | Data_TyVars_Sum_Args1_Ignored 105 | 106 | data Data_TyVars_Sum_Args2 :: Type -> Type -> Type -> Type -> Type 107 | data Data_TyVars_Sum_Args2 a b c d 108 | = Data_TyVars_Sum_Args2 a b 109 | | Data_TyVars_Sum_Args2_Ignored 110 | 111 | data Data_TyVars_Sum_Args3 :: Type -> Type -> Type -> Type -> Type 112 | data Data_TyVars_Sum_Args3 a b c d 113 | = Data_TyVars_Sum_Args3 a b c 114 | | Data_TyVars_Sum_Args3_Ignored 115 | 116 | data Data_Wrapping_Record a b c 117 | = Data_Wrapping_Record 118 | { recordFieldReferencedInExportedData :: a 119 | } 120 | 121 | type TypeAlias_Record = 122 | { recordFieldReferencedInExportedTypeAlias :: Int 123 | , bar :: String 124 | , baz :: Boolean 125 | } 126 | 127 | type TypeAlias_Type = String 128 | 129 | newtype NewtypedRecord = NewtypedRecord 130 | { first :: String 131 | , second :: String 132 | } 133 | derive instance newtypeNewtypedRecord :: Newtype NewtypedRecord _ 134 | 135 | newtype NewtypedRecordWithTyVars a b = NewtypedRecordWithTyVars 136 | { first :: a 137 | , second :: b 138 | } 139 | derive instance newtypeNewtypedRecordWithTyVars :: Newtype (NewtypedRecordWithTyVars a b) _ 140 | 141 | newtype NewtypedType = NewtypedType Int 142 | derive instance newtypeNewtypedType :: Newtype NewtypedType _ 143 | 144 | data DataDefinedInSourceFile = DataDefinedInSourceFile 145 | newtype NewtypeDefinedInSourceFile = NewtypeDefinedInSourceFile Int 146 | derive instance newtypeNewtypeDefinedInSourceFile :: Newtype NewtypeDefinedInSourceFile _ 147 | type AliasDefinedInSourceFile = Int 148 | foreign import data FfiTypeDefinedInSourceFile :: Type 149 | 150 | data Data_Product_ImportedTypesAreReimported 151 | = Data_Product_ImportedTypesAreReimported 152 | (MyData Int Int Int) (MyAlias String) (MyNewtype Int Int Int) 153 | (Q.MyData Int Int Int) (Q.MyAlias String) (Q.MyNewtype Int Int Int) 154 | (Shared.MyData Int Int Int) (Shared.MyAlias String) (Shared.MyNewtype Int Int Int) 155 | DataDefinedInSourceFile NewtypeDefinedInSourceFile AliasDefinedInSourceFile FfiTypeDefinedInSourceFile 156 | 157 | data Data_Sum_ImportedTypesAreReimported 158 | = Data_Sum_ImportedTypesAreReimported 159 | (MyData Int Int Int) (MyAlias String) (MyNewtype Int Int Int) 160 | (Q.MyData Int Int Int) (Q.MyAlias String) (Q.MyNewtype Int Int Int) 161 | (Shared.MyData Int Int Int) (Shared.MyAlias String) (Shared.MyNewtype Int Int Int) 162 | DataDefinedInSourceFile NewtypeDefinedInSourceFile AliasDefinedInSourceFile FfiTypeDefinedInSourceFile 163 | | Data_Sum_ImportedTypesAreReimported_IgnoredCase 164 | 165 | newtype Record_ImportedTypesAreReimported = Record_ImportedTypesAreReimported 166 | { noAlias :: 167 | { myData :: MyData Int Int Int 168 | , myAlias :: MyAlias String 169 | , myNewtype :: MyNewtype Int Int Int 170 | } 171 | , aliasOnly :: 172 | { myData :: Q.MyData Int Int Int 173 | , myAlias :: Q.MyAlias String 174 | , myNewtype :: Q.MyNewtype Int Int Int 175 | } 176 | , sharedAlias :: 177 | { myData :: Shared.MyData Int Int Int 178 | , myAlias :: Shared.MyAlias String 179 | , myNewtype :: Shared.MyNewtype Int Int Int 180 | } 181 | , definedInSourceFile :: 182 | { myData :: DataDefinedInSourceFile 183 | , myAlias :: AliasDefinedInSourceFile 184 | , myNewtype :: NewtypeDefinedInSourceFile 185 | , myFfi :: FfiTypeDefinedInSourceFile 186 | } 187 | } 188 | derive instance newtypeRecord_ImportedTypesAreReimported :: Newtype Record_ImportedTypesAreReimported _ 189 | 190 | data Data_TypeNotExported = Data_TypeNotExported 191 | data Data_TypeOnlyExported = Data_TypeOnlyExported 192 | data Data_TypeExported_CtorExported_Product_All = Data_TypeExported_CtorExported_Product_All 193 | data Data_TypeExported_CtorExported_Product_ByName = Data_TypeExported_CtorExported_Product_ByName 194 | data Data_TypeExported_CtorExported_Sum_All 195 | = Data_TypeExported_CtorExported_Sum_All_1 196 | | Data_TypeExported_CtorExported_Sum_All_2 197 | 198 | data Data_TypeExported_CtorExported_Sum_ByName 199 | = Data_TypeExported_CtorExported_Sum_ByName_Exported 200 | | Data_TypeExported_CtorExported_Sum_ByName_NotExpored 201 | 202 | type TypeAlias_TypeNotExported = Int 203 | type TypeAlias_TypeExported = Int 204 | 205 | newtype Newtype_TypeNotExported = Newtype_TypeNotExported Int 206 | derive instance newtypeNewtype_TypeNotExported :: Newtype Newtype_TypeNotExported _ 207 | 208 | newtype Newtype_TypeOnlyExported = Newtype_TypeOnlyExported Int 209 | derive instance newtypeNewtype_TypeOnlyExported :: Newtype Newtype_TypeOnlyExported _ 210 | 211 | newtype Newtype_TypeExported_CtorExported_All = Newtype_TypeExported_CtorExported_All Int 212 | derive instance newtypeNewtype_TypeExported_CtorExported_All :: Newtype Newtype_TypeExported_CtorExported_All _ 213 | 214 | newtype Newtype_TypeExported_CtorExported_ByName = Newtype_TypeExported_CtorExported_ByName Int 215 | derive instance Newtype Newtype_TypeExported_CtorExported_ByName _ 216 | 217 | newtype Newtype_TypeExported_CtorExported_NoDerivedNewtypeInstance = Newtype_TypeExported_CtorExported_NoDerivedNewtypeInstance Int 218 | -- derive instance :: Newtype Newtype_TypeExported_CtorExported_NoDerivedNewtypeInstance _ 219 | 220 | data CustomKind :: Type 221 | data KindedTyVars (f :: CustomKind -> Type) = KindedTyVars 222 | 223 | data EnsureSharedImportIsUsed = 224 | EnsureSharedImportIsUsed 225 | (Shared.SharedMyData Int Int Int) (Shared.SharedMyAlias String) (Shared.SharedMyNewtype Int Int Int) 226 | 227 | usePrelude :: String 228 | usePrelude = show 1 229 | -------------------------------------------------------------------------------- /snapshots/UseAbcLabelStyle.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseAbcLabelStyle where 2 | 3 | data Product a b c d e f g h = Product a b c d e f g h 4 | 5 | data Sum a b c d e f g h 6 | = Ignore 7 | | Sum a b c d e f g h 8 | -------------------------------------------------------------------------------- /snapshots/UseAbcLabelStyle/Lens.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseAbcLabelStyle.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso (iso) 6 | import Data.Lens.Prism (Prism', prism) 7 | import Data.Lens.Record (prop) 8 | import Prelude (Unit, const, unit) 9 | import Snapshots.UseAbcLabelStyle (Product(..), Sum(..)) 10 | import Type.Proxy (Proxy(..)) 11 | 12 | _Product 13 | :: forall a b c d e f g h 14 | . Lens' (Product a b c d e f g h) 15 | { a :: a, b :: b, c :: c, d :: d, e :: e, f :: f, g :: g, h :: h } 16 | _Product = iso (\(Product a b c d e f g h) -> { a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h }) 17 | \{ a, b, c, d, e, f, g, h } -> Product a b c d e f g h 18 | 19 | _Ignore :: forall a b c d e f g h. Prism' (Sum a b c d e f g h) Unit 20 | _Ignore = prism (const Ignore) case _ of 21 | Ignore -> Right unit 22 | other -> Left other 23 | 24 | _Sum 25 | :: forall a b c d e f g h 26 | . Prism' (Sum a b c d e f g h) { a :: a, b :: b, c :: c, d :: d, e :: e, f :: f, g :: g, h :: h } 27 | _Sum = prism (\{ a, b, c, d, e, f, g, h } -> Sum a b c d e f g h) case _ of 28 | Sum a b c d e f g h -> Right { a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h } 29 | other -> Left other 30 | 31 | _propA :: forall r a. Lens' { a :: a | r } a 32 | _propA = prop (Proxy :: Proxy "a") 33 | 34 | _propB :: forall r a. Lens' { b :: a | r } a 35 | _propB = prop (Proxy :: Proxy "b") 36 | 37 | _propC :: forall r a. Lens' { c :: a | r } a 38 | _propC = prop (Proxy :: Proxy "c") 39 | 40 | _propD :: forall r a. Lens' { d :: a | r } a 41 | _propD = prop (Proxy :: Proxy "d") 42 | 43 | _propE :: forall r a. Lens' { e :: a | r } a 44 | _propE = prop (Proxy :: Proxy "e") 45 | 46 | _propF :: forall r a. Lens' { f :: a | r } a 47 | _propF = prop (Proxy :: Proxy "f") 48 | 49 | _propG :: forall r a. Lens' { g :: a | r } a 50 | _propG = prop (Proxy :: Proxy "g") 51 | 52 | _propH :: forall r a. Lens' { h :: a | r } a 53 | _propH = prop (Proxy :: Proxy "h") 54 | -------------------------------------------------------------------------------- /snapshots/UseArgLabelStyle.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseArgLabelStyle where 2 | 3 | data Product a b c d e f g h = Product a b c d e f g h 4 | 5 | data Sum a b c d e f g h 6 | = Ignore 7 | | Sum a b c d e f g h 8 | -------------------------------------------------------------------------------- /snapshots/UseArgLabelStyle/Lens.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseArgLabelStyle.Lens where 2 | 3 | import Data.Either (Either(..)) 4 | import Data.Lens (Lens') 5 | import Data.Lens.Iso (iso) 6 | import Data.Lens.Prism (Prism', prism) 7 | import Data.Lens.Record (prop) 8 | import Prelude (Unit, const, unit) 9 | import Snapshots.UseArgLabelStyle (Product(..), Sum(..)) 10 | import Type.Proxy (Proxy(..)) 11 | 12 | _Product 13 | :: forall a b c d e f g h 14 | . Lens' (Product a b c d e f g h) 15 | { arg1 :: a, arg2 :: b, arg3 :: c, arg4 :: d, arg5 :: e, arg6 :: f, arg7 :: g, arg8 :: h } 16 | _Product = iso 17 | ( \(Product arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8) -> 18 | { arg1: arg1 19 | , arg2: arg2 20 | , arg3: arg3 21 | , arg4: arg4 22 | , arg5: arg5 23 | , arg6: arg6 24 | , arg7: arg7 25 | , arg8: arg8 26 | } 27 | ) 28 | \{ arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 } -> Product arg1 arg2 arg3 arg4 arg5 arg6 arg7 29 | arg8 30 | 31 | _Ignore :: forall a b c d e f g h. Prism' (Sum a b c d e f g h) Unit 32 | _Ignore = prism (const Ignore) case _ of 33 | Ignore -> Right unit 34 | other -> Left other 35 | 36 | _Sum 37 | :: forall a b c d e f g h 38 | . Prism' (Sum a b c d e f g h) 39 | { arg1 :: a, arg2 :: b, arg3 :: c, arg4 :: d, arg5 :: e, arg6 :: f, arg7 :: g, arg8 :: h } 40 | _Sum = prism 41 | ( \{ arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 } -> Sum arg1 arg2 arg3 arg4 arg5 arg6 arg7 42 | arg8 43 | ) 44 | case _ of 45 | Sum arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 -> Right 46 | { arg1: arg1 47 | , arg2: arg2 48 | , arg3: arg3 49 | , arg4: arg4 50 | , arg5: arg5 51 | , arg6: arg6 52 | , arg7: arg7 53 | , arg8: arg8 54 | } 55 | other -> Left other 56 | 57 | _propArg1 :: forall r a. Lens' { arg1 :: a | r } a 58 | _propArg1 = prop (Proxy :: Proxy "arg1") 59 | 60 | _propArg2 :: forall r a. Lens' { arg2 :: a | r } a 61 | _propArg2 = prop (Proxy :: Proxy "arg2") 62 | 63 | _propArg3 :: forall r a. Lens' { arg3 :: a | r } a 64 | _propArg3 = prop (Proxy :: Proxy "arg3") 65 | 66 | _propArg4 :: forall r a. Lens' { arg4 :: a | r } a 67 | _propArg4 = prop (Proxy :: Proxy "arg4") 68 | 69 | _propArg5 :: forall r a. Lens' { arg5 :: a | r } a 70 | _propArg5 = prop (Proxy :: Proxy "arg5") 71 | 72 | _propArg6 :: forall r a. Lens' { arg6 :: a | r } a 73 | _propArg6 = prop (Proxy :: Proxy "arg6") 74 | 75 | _propArg7 :: forall r a. Lens' { arg7 :: a | r } a 76 | _propArg7 = prop (Proxy :: Proxy "arg7") 77 | 78 | _propArg8 :: forall r a. Lens' { arg8 :: a | r } a 79 | _propArg8 = prop (Proxy :: Proxy "arg8") 80 | -------------------------------------------------------------------------------- /snapshots/UseGlobalPropFile/GlobalRecordLens.purs: -------------------------------------------------------------------------------- 1 | module UseGlobalPropFile.GlobalRecordLens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Record (prop) 5 | import Type.Proxy (Proxy(..)) 6 | 7 | _propBumblebee :: forall r a. Lens' { bumblebee :: a | r } a 8 | _propBumblebee = prop (Proxy :: Proxy "bumblebee") 9 | 10 | _propQuarts :: forall r a. Lens' { quarts :: a | r } a 11 | _propQuarts = prop (Proxy :: Proxy "quarts") 12 | 13 | _prop力 :: forall r a. Lens' { "力" :: a | r } a 14 | _prop力 = prop (Proxy :: Proxy "力") 15 | -------------------------------------------------------------------------------- /snapshots/UseGlobalPropFile/Module1.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseGlobalPropFile.Module1 where 2 | 3 | type SameLabelsAsOtherModule = 4 | { quarts :: String 5 | , bumblebee :: String 6 | , "力" :: String 7 | } 8 | -------------------------------------------------------------------------------- /snapshots/UseGlobalPropFile/Module2.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseGlobalPropFile.Module2 where 2 | 3 | type SameLabelsAsOtherModule = 4 | { quarts :: String 5 | , bumblebee :: String 6 | , "力" :: String 7 | } 8 | -------------------------------------------------------------------------------- /snapshots/UseLabelPrefix.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseLabelPrefix where 2 | 3 | import Data.Newtype (class Newtype) 4 | 5 | data Foo = Foo { a :: Int, b :: String } 6 | 7 | newtype Bar = Bar { height :: Number } 8 | 9 | derive instance newtypeBar :: Newtype Bar _ 10 | -------------------------------------------------------------------------------- /snapshots/UseLabelPrefix/Lens.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseLabelPrefix.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Lens.Record (prop) 7 | import Snapshots.UseLabelPrefix (Bar, Foo(..)) 8 | import Type.Proxy (Proxy(..)) 9 | 10 | _Foo :: Lens' Foo { a :: Int, b :: String } 11 | _Foo = iso (\(Foo a) -> a) Foo 12 | 13 | _Bar :: Lens' Bar { height :: Number } 14 | _Bar = _Newtype 15 | 16 | _propA :: forall r a. Lens' { a :: a | r } a 17 | _propA = prop (Proxy :: Proxy "a") 18 | 19 | _propB :: forall r a. Lens' { b :: a | r } a 20 | _propB = prop (Proxy :: Proxy "b") 21 | 22 | _propHeight :: forall r a. Lens' { height :: a | r } a 23 | _propHeight = prop (Proxy :: Proxy "height") 24 | -------------------------------------------------------------------------------- /snapshots/UseLocalProps/Module1.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseLocalProps.Module1 where 2 | 3 | type SameLabelsAsOtherModule = 4 | { quarts :: String 5 | , bumblebee :: String 6 | , "力" :: String 7 | } 8 | -------------------------------------------------------------------------------- /snapshots/UseLocalProps/Module1/Lens.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseLocalProps.Module1.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Record (prop) 5 | import Type.Proxy (Proxy(..)) 6 | 7 | _propBumblebee :: forall r a. Lens' { bumblebee :: a | r } a 8 | _propBumblebee = prop (Proxy :: Proxy "bumblebee") 9 | 10 | _propQuarts :: forall r a. Lens' { quarts :: a | r } a 11 | _propQuarts = prop (Proxy :: Proxy "quarts") 12 | 13 | _prop力 :: forall r a. Lens' { "力" :: a | r } a 14 | _prop力 = prop (Proxy :: Proxy "力") 15 | -------------------------------------------------------------------------------- /snapshots/UseLocalProps/Module2.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseLocalProps.Module2 where 2 | 3 | type SameLabelsAsOtherModule = 4 | { quarts :: String 5 | , bumblebee :: String 6 | , "力" :: String 7 | } 8 | -------------------------------------------------------------------------------- /snapshots/UseLocalProps/Module2/Lens.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseLocalProps.Module2.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Record (prop) 5 | import Type.Proxy (Proxy(..)) 6 | 7 | _propBumblebee :: forall r a. Lens' { bumblebee :: a | r } a 8 | _propBumblebee = prop (Proxy :: Proxy "bumblebee") 9 | 10 | _propQuarts :: forall r a. Lens' { quarts :: a | r } a 11 | _propQuarts = prop (Proxy :: Proxy "quarts") 12 | 13 | _prop力 :: forall r a. Lens' { "力" :: a | r } a 14 | _prop力 = prop (Proxy :: Proxy "力") 15 | -------------------------------------------------------------------------------- /snapshots/UseNoLabelPrefix.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseNoLabelPrefix where 2 | 3 | import Data.Newtype (class Newtype) 4 | 5 | data Foo = Foo { a :: Int, b :: String } 6 | 7 | newtype Bar = Bar { height :: Number } 8 | 9 | derive instance newtypeBar :: Newtype Bar _ 10 | -------------------------------------------------------------------------------- /snapshots/UseNoLabelPrefix/Lens.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseNoLabelPrefix.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (iso) 5 | import Data.Lens.Iso.Newtype (_Newtype) 6 | import Data.Lens.Record (prop) 7 | import Snapshots.UseNoLabelPrefix (Bar, Foo(..)) 8 | import Type.Proxy (Proxy(..)) 9 | 10 | _Foo :: Lens' Foo { a :: Int, b :: String } 11 | _Foo = iso (\(Foo a) -> a) Foo 12 | 13 | _Bar :: Lens' Bar { height :: Number } 14 | _Bar = _Newtype 15 | 16 | _a :: forall r a. Lens' { a :: a | r } a 17 | _a = prop (Proxy :: Proxy "a") 18 | 19 | _b :: forall r a. Lens' { b :: a | r } a 20 | _b = prop (Proxy :: Proxy "b") 21 | 22 | _height :: forall r a. Lens' { height :: a | r } a 23 | _height = prop (Proxy :: Proxy "height") 24 | -------------------------------------------------------------------------------- /snapshots/UseTypeAliases.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseTypeAliases where 2 | 3 | type TypeAlias_Record = 4 | { foo :: Int 5 | , bar :: String 6 | , baz :: Boolean 7 | } 8 | 9 | type TypeAlias_String = String 10 | 11 | type TypeAlias_ArrayString = Array String 12 | -------------------------------------------------------------------------------- /snapshots/UseTypeAliases/Lens.purs: -------------------------------------------------------------------------------- 1 | module Snapshots.UseTypeAliases.Lens where 2 | 3 | import Data.Lens (Lens') 4 | import Data.Lens.Iso (Iso') 5 | import Data.Lens.Record (prop) 6 | import Prelude (identity) 7 | import Snapshots.UseTypeAliases (TypeAlias_ArrayString, TypeAlias_Record, TypeAlias_String) 8 | import Type.Proxy (Proxy(..)) 9 | 10 | _TypeAlias_Record :: Iso' TypeAlias_Record 11 | { foo :: Int 12 | , bar :: String 13 | , baz :: Boolean 14 | } 15 | _TypeAlias_Record = identity 16 | 17 | _TypeAlias_String :: Iso' TypeAlias_String String 18 | _TypeAlias_String = identity 19 | 20 | _TypeAlias_ArrayString :: Iso' TypeAlias_ArrayString (Array String) 21 | _TypeAlias_ArrayString = identity 22 | 23 | _propBar :: forall r a. Lens' { bar :: a | r } a 24 | _propBar = prop (Proxy :: Proxy "bar") 25 | 26 | _propBaz :: forall r a. Lens' { baz :: a | r } a 27 | _propBaz = prop (Proxy :: Proxy "baz") 28 | 29 | _propFoo :: forall r a. Lens' { foo :: a | r } a 30 | _propFoo = prop (Proxy :: Proxy "foo") 31 | -------------------------------------------------------------------------------- /spago.dhall: -------------------------------------------------------------------------------- 1 | { name = "my-project" 2 | , dependencies = 3 | [ "aff" 4 | , "argparse-basic" 5 | , "arrays" 6 | , "console" 7 | , "control" 8 | , "effect" 9 | , "either" 10 | , "exceptions" 11 | , "foldable-traversable" 12 | , "free" 13 | , "identity" 14 | , "integers" 15 | , "language-cst-parser" 16 | , "maybe" 17 | , "newtype" 18 | , "node-buffer" 19 | , "node-fs" 20 | , "node-fs-aff" 21 | , "node-glob-basic" 22 | , "node-path" 23 | , "node-process" 24 | , "ordered-collections" 25 | , "partial" 26 | , "prelude" 27 | , "psci-support" 28 | , "refs" 29 | , "safe-coerce" 30 | , "strings" 31 | , "tidy-codegen" 32 | , "transformers" 33 | , "tuples" 34 | ] 35 | , packages = ./packages.dhall 36 | , sources = [ "src/**/*.purs", "test/**/*.purs" ] 37 | } 38 | -------------------------------------------------------------------------------- /src/CLI.purs: -------------------------------------------------------------------------------- 1 | module CLI where 2 | 3 | import Prelude 4 | 5 | import ArgParse.Basic (ArgError, anyNotFlag, argument, boolean, choose, default, flag, flagHelp, flagInfo, fromRecord, optional, parseArgs, unfolded1, unformat) 6 | import Control.Monad.Error.Class (throwError) 7 | import Data.Array (fold) 8 | import Data.Array as Array 9 | import Data.Either (Either) 10 | import Data.Foldable (for_) 11 | import Data.FoldableWithIndex (findWithIndex) 12 | import Data.Int as Int 13 | import Data.Maybe (Maybe(..)) 14 | import Data.String (Pattern(..), joinWith) 15 | import Data.String as String 16 | import Data.String.NonEmpty.Internal (NonEmptyString, liftS) 17 | import Data.String.NonEmpty.Internal as NES 18 | import Data.String.Regex (test) 19 | import Data.String.Regex.Flags (noFlags) 20 | import Data.String.Regex.Unsafe (unsafeRegex) 21 | import Node.Path (FilePath) 22 | import Node.Path as Path 23 | import Types (RecordLabelStyle(..)) 24 | import Version (versionStr) 25 | 26 | type CliArgs = 27 | { 28 | -- | Some type alises refer to records 29 | -- | ``` 30 | -- | type Foo = { a :: Int } 31 | -- | ``` 32 | -- | So, a lens is generated for the `a` label. 33 | -- | 34 | -- | Other type aliases refer to non record types 35 | -- | ``` 36 | -- | type Foo = Wrapped (Label (Name Proper) (Type Void)) 37 | -- | ``` 38 | -- | It can be hard to know what `Foo` refers to. So 39 | -- | rather than remembering to write `_Wrapped` when one 40 | -- | comes across a `Foo`, one can write `_Foo`, ask the compiler 41 | -- | for help via typed holes, and then be directed by the compiler 42 | -- | to use `_Wrapped`. 43 | -- | The intermediary `_Foo` can be removed once 44 | -- | one becomes more familiar with a libary's type aliases. 45 | genTypeAliasLens :: Boolean 46 | , 47 | -- | Multiple types may refer to the same label name 48 | -- | across multiple files... 49 | -- | ``` 50 | -- | // Foo.purs 51 | -- | type Foo = { val :: Int } 52 | -- | type Bar = { val :: String } 53 | -- | // Baz.purs 54 | -- | type Baz = { val :: Char } 55 | -- | ``` 56 | -- | By default, each module's `Lens.purs` file 57 | -- | will include a lens for each label referenced 58 | -- | in that file. However, this can lead to 59 | -- | importing lenses from different modules 60 | -- | that do the same thing: 61 | -- | ``` 62 | -- | import Foo (_propA) 63 | -- | import Baz (_propA) 64 | -- | 65 | -- | // where `_propA` is 66 | -- | _propVal :: forall a r. Lens' { val :: a | r } a 67 | -- | _propVal :: prop (Proxy :: Proxy "val") 68 | -- | ``` 69 | -- | 70 | -- | Enabling this feature means a single `RecordLens.purs` 71 | -- | file will be generated where each label's lens 72 | -- | is generated only once. 73 | genGlobalPropFile :: Maybe { filePath :: FilePath, modulePath :: String } 74 | 75 | , 76 | -- | By default, this will be "prop", so that a record label `{ foo :: a }` 77 | -- | will have the `_propFoo` generated for it. 78 | -- | If this value is empty, the label generated will instead be 79 | -- | `_foo`. 80 | labelPrefix :: Maybe NonEmptyString 81 | 82 | , 83 | -- | When there are data constructors with 3+ arguments 84 | -- | we could convert the value into a nested `Tuple` 85 | -- | but that seems less user-friendly than just using 86 | -- | a record. 87 | -- | However, what should the record's labels be? 88 | -- | We can use two styles: 89 | -- | - `AlphabetRecordLabels`: `Foo a b c d -> { a, b, c, d }` 90 | -- | - `ArgRecordLabels`: `Foo a b c d -> { arg1: a, arg2: b, arg3: c, arg4: d }` 91 | recordLabelStyle :: RecordLabelStyle 92 | , outputDir :: String 93 | } 94 | 95 | type PrefixedGlob = 96 | { glob :: String 97 | , dirCount :: Int 98 | } 99 | 100 | parseCliArgs :: Array String -> Either ArgError { prefixedGlobs :: Array PrefixedGlob, options :: CliArgs } 101 | parseCliArgs = 102 | parseArgs 103 | "tidy-mklens" 104 | ( joinWith "\n" 105 | [ "A CLI for generating optics for your data types" 106 | , "" 107 | , "Expected usage: " 108 | , " tidy-mklens [OPTIONS] PURS_GLOBS..." 109 | , "" 110 | , "Examples:" 111 | , " tidy-mklens src" 112 | , " tidy-mklens --global-record-lens-module RecordLens src" 113 | , " tidy-mklens --label-style-abc src" 114 | , " tidy-mklens --gen-type-alias-lenses src" 115 | , " tidy-mklens --output-dir src .spago/*/*/src/**/*.purs:4" 116 | ] 117 | ) 118 | parser 119 | where 120 | parser = 121 | { prefixedGlobs: _, options: _ } 122 | <$> pursGlobs 123 | <*> fromRecord 124 | { genTypeAliasLens 125 | , genGlobalPropFile 126 | , recordLabelStyle 127 | , labelPrefix 128 | , outputDir 129 | } 130 | <* flagInfo [ "--version", "-v" ] "Shows the current version" versionStr 131 | <* flagHelp 132 | 133 | labelPrefix = 134 | choose "Label prefix" 135 | [ Nothing <$ flag [ "--label-prefix-none", "-n" ] "Use '_foo' for the lens for a record '{ foo :: a }'" 136 | , argument [ "--label-prefix", "-l" ] "Use `_PREFIXFoo` for the lens for a record '{ foo :: a }'" 137 | # unformat "PREFIX" validatePrefix 138 | ] 139 | # default (NES.fromString "prop") 140 | where 141 | validatePrefix s = do 142 | case NES.fromString s of 143 | Nothing -> do 144 | throwError $ "Invalid label prefix. Prefix must not be empty" 145 | x@(Just nes) -> do 146 | unless (liftS (test alphaNumUnderscoreRegex) nes) do 147 | throwError $ "Invalid label prefix. '" <> s <> "' must pass the '^[a-zA-Z0-9_]+$' regex." 148 | pure x 149 | 150 | where 151 | alphaNumUnderscoreRegex = unsafeRegex "^[a-zA-Z0-9_]+$" noFlags 152 | 153 | genTypeAliasLens = 154 | flag 155 | [ "--gen-type-alias-isos", "-t" ] 156 | "Generate isos for type aliases" 157 | # boolean 158 | 159 | genGlobalPropFile = 160 | optional 161 | ( argument [ "--global-record-lens-module", "-m" ] description 162 | # unformat "MODULE_PATH" validateModulePath 163 | ) 164 | where 165 | description = joinWith "" 166 | [ "The full module path to use for the single record label lenses file (e.g `Foo.Bar.Lens`). " 167 | , "The module will be outtputed to a file based on the module path (e.g. `Foo.Bar.Lens` " 168 | , "will be saved to `/Foo/Bar/Lens.purs`)." 169 | ] 170 | validateModulePath s = do 171 | when (s == "") do 172 | throwError "Invalid module path. Module path must not be an empty string" 173 | let 174 | segments = String.split (Pattern ".") s 175 | alphaNumUnderscoreCheck = segments # findWithIndex \_ next -> 176 | not $ test alphaNumUnderscoreRegex next 177 | firstCharCheck = segments # findWithIndex \_ -> not $ firstCharIsUppercase 178 | 179 | for_ alphaNumUnderscoreCheck \r -> 180 | throwError $ "Invalid module path. Segment at index " <> show r.index <> ", '" <> r.value <> "', does not pass `[a-zA-Z0-9_]+` regex check" 181 | 182 | for_ firstCharCheck \r -> 183 | throwError $ "Invalid module path. First character for segment at index " <> show r.index <> ", '" <> r.value <> "', is not uppercased" 184 | 185 | case Array.unsnoc segments of 186 | Nothing -> 187 | throwError "Invalid module path. Module path does not contain any segments." 188 | Just { init, last } -> 189 | pure { modulePath: s, filePath: Path.concat $ Array.snoc init $ last <> ".purs" } 190 | 191 | firstCharIsUppercase s = do 192 | let firstChar = String.take 1 s 193 | firstChar == "_" || firstChar == String.toUpper firstChar 194 | 195 | alphaNumUnderscoreRegex = unsafeRegex "^[a-zA-Z0-9_]+$" noFlags 196 | 197 | recordLabelStyle = 198 | choose "Record label style" 199 | [ ArgRecordLabels <$ flag [ "--label-style-arg", "-a" ] 200 | "Data constructors with 3+ args will use record labels of 'argN' (e.g. 'arg1', 'arg2', ..., 'argN')" 201 | , AlphabetRecordLabels <$ flag [ "--label-style-abc", "-b" ] 202 | "Data constructors with 3+ args will use record labels based on the alphabet (e.g. 'a', 'b', ..., 'z', 'aa', 'ab', ...)" 203 | ] 204 | # default ArgRecordLabels 205 | 206 | outputDir = 207 | argument [ "--output-dir", "-o" ] "The directory into which to write the generated files (defaults to `src`)." 208 | # default "src" 209 | 210 | pursGlobs = 211 | anyNotFlag globExample description 212 | # unformat globExample validate 213 | # unfolded1 214 | where 215 | description = joinWith "" 216 | [ "Globs for PureScript sources (e.g. `src` `test/**/*.purs`) " 217 | , "and the number of root directories to strip from each file path (defaults to 1) " 218 | , "that are separated by the OS-specific path delimiter (POSIX: ':', Windows: ';'), " 219 | ] 220 | delimit l r = l <> Path.delimiter <> r 221 | globExample = delimit "GLOB[" "DIR_STRIP_COUNT]" 222 | validate s = do 223 | case String.split (String.Pattern Path.delimiter) s of 224 | [ glob, dirStripCount ] 225 | | Just dirCount <- Int.fromString dirStripCount -> pure { glob, dirCount } 226 | | otherwise -> throwError $ fold 227 | [ "Invalid source glob. Expected directory strip count to be an integer " 228 | , "but was '" 229 | , s 230 | , "'" 231 | ] 232 | 233 | [ glob ] -> pure { glob, dirCount: 1 } 234 | _ -> throwError $ joinWith "" 235 | [ "Invalid source glob. Expected either a glob (e.g. `src`) " 236 | , "or a glob and the prefix to strip separated by a '" 237 | , Path.delimiter 238 | , "' character " 239 | , "(e.g. `" 240 | , delimit ".spago/*/*/src/**/*.purs" "4" 241 | , "`)" 242 | ] 243 | -------------------------------------------------------------------------------- /src/Main.purs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Prelude 4 | 5 | import ArgParse.Basic (ArgError(..), ArgErrorMsg(..), printArgError) 6 | import CLI (PrefixedGlob, parseCliArgs) 7 | import Data.Array (drop) 8 | import Data.Array as Array 9 | import Data.Array.NonEmpty as NEA 10 | import Data.Either (Either(..)) 11 | import Data.Foldable (foldl, for_, surround) 12 | import Data.Map as Map 13 | import Data.Maybe (Maybe(..), isJust) 14 | import Data.Set as Set 15 | import Data.String (Pattern(..), joinWith, stripSuffix) 16 | import Data.String as String 17 | import Data.Traversable (for, traverse) 18 | import Data.Tuple (Tuple(..)) 19 | import Effect (Effect) 20 | import Effect.Aff (Aff, launchAff_) 21 | import Effect.Class (liftEffect) 22 | import Effect.Class.Console (log) 23 | import Effect.Exception (throw) 24 | import Effect.Ref as Ref 25 | import MkLens (FileInfo, genLensProp, generateLensModule) 26 | import Node.Encoding (Encoding(..)) 27 | import Node.FS.Aff as FSA 28 | import Node.FS.Stats as Stats 29 | import Node.Glob.Basic (expandGlobsWithStatsCwd) 30 | import Node.Path (dirname) 31 | import Node.Path as Path 32 | import Node.Process (argv) 33 | import Node.Process as Process 34 | import Partial.Unsafe (unsafePartial) 35 | import Tidy.Codegen (printModule) 36 | import Tidy.Codegen.Monad (codegenModule) 37 | 38 | main :: Effect Unit 39 | main = do 40 | args <- map (drop 2) argv 41 | case parseCliArgs args of 42 | Left e -> do 43 | log $ printArgError e 44 | case e of 45 | ArgError _ ShowHelp -> 46 | Process.exit 0 47 | ArgError _ (ShowInfo _) -> 48 | Process.exit 0 49 | _ -> 50 | Process.exit 1 51 | Right { prefixedGlobs, options } -> launchAff_ do 52 | files <- globsToFileInfo options.outputDir prefixedGlobs 53 | labelSets <- traverse (generateLensModule options) files 54 | for_ options.genGlobalPropFile \{ filePath, modulePath } -> do 55 | let 56 | labelNameSet = Array.foldl Set.union Set.empty labelSets 57 | globalPropFile = Path.concat [ options.outputDir, filePath ] 58 | unless (Set.isEmpty labelNameSet) do 59 | let 60 | content = printModule $ unsafePartial $ codegenModule modulePath do 61 | genLensProp options.labelPrefix labelNameSet 62 | unlessM (FSA.exists $ dirname globalPropFile) do 63 | FSA.mkdir $ dirname globalPropFile 64 | FSA.writeTextFile UTF8 globalPropFile content 65 | 66 | globsToFileInfo :: String -> Array PrefixedGlob -> Aff (Array FileInfo) 67 | globsToFileInfo outputDir = map join <<< traverse \{ glob, dirCount } -> do 68 | globFiles <- expandGlobs [ glob ] 69 | 70 | outputFilesRef <- liftEffect $ Ref.new Map.empty 71 | 72 | fileInfo <- for globFiles \file -> do 73 | let 74 | originalDirPlusFile = Path.concat 75 | [ Path.dirname file 76 | , Path.basenameWithoutExt file (Path.extname file) 77 | ] 78 | -- Per the Node docs 79 | -- (https://nodejs.org/api/path.html#pathrelativefrom-to), 80 | -- if an empty string is passed in as the 'from' 81 | -- then the current working directory will be used. 82 | relativePath = Path.relative "" originalDirPlusFile 83 | outputDirOutputFile = Path.concat 84 | $ Array.cons outputDir 85 | $ flip Array.snoc "Lens.purs" 86 | $ drop dirCount 87 | $ String.split (String.Pattern Path.sep) relativePath 88 | 89 | liftEffect $ flip Ref.modify_ outputFilesRef \m -> 90 | Map.alter 91 | case _ of 92 | Nothing -> Just $ Set.singleton file 93 | Just prev -> Just $ Set.insert file prev 94 | outputDirOutputFile 95 | m 96 | pure { inputFile: file, outputFile: outputDirOutputFile } 97 | 98 | liftEffect do 99 | outputtedFiles <- Ref.read outputFilesRef 100 | for_ (NEA.fromArray $ Map.toUnfoldable $ Map.filter (\r -> Set.size r /= 1) outputtedFiles) \nea -> do 101 | throw 102 | $ joinWith "" 103 | [ "Error in source glob: '" 104 | , glob 105 | , "'. Error in DIR_STRIP_COUNT arg: '" 106 | , show dirCount 107 | , "'. Found a case where the following input files' generated optics content would be " 108 | , "outputted into the same file. Later file's output would overwrite earlier file's output. " 109 | , "To fix, decrease the DIR_STRIP_COUNT part of the source glob." 110 | , foldl (<>) "\n" $ nea <#> \(Tuple outFile inputFiles) -> joinWith "\n" 111 | [ "Output file: " 112 | , "\t" <> outFile 113 | , append "Input files:" $ surround "\n\t" inputFiles 114 | ] 115 | ] 116 | 117 | pure fileInfo 118 | 119 | -- Note: credit for the below code goes to @natefaubion 120 | -- since this was copied from `natefaubion/purescript-tidy` 121 | expandGlobs :: Array String -> Aff (Array String) 122 | expandGlobs = map dirToGlob >>> expandGlobsWithStatsCwd >>> map onlyFiles 123 | where 124 | dirToGlob path = 125 | if Path.extname path == "" then 126 | if isJust (stripSuffix (Pattern "**") path) then 127 | Path.concat [ path, "*.purs" ] 128 | else 129 | Path.concat [ path, "**", "*.purs" ] 130 | else 131 | path 132 | 133 | onlyFiles = 134 | Map.filter Stats.isFile 135 | >>> Map.keys 136 | >>> Set.toUnfoldable 137 | -------------------------------------------------------------------------------- /src/MkDir.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | exports.mkdirRec = (path) => (cb) => () => fs.mkdir(path, { recursive: true }, cb); 4 | -------------------------------------------------------------------------------- /src/MkDir.purs: -------------------------------------------------------------------------------- 1 | module MkDir where 2 | 3 | import Prelude 4 | 5 | import Data.Either (Either(..)) 6 | import Effect (Effect) 7 | import Effect.Aff (Aff, makeAff, nonCanceler) 8 | import Node.Path (FilePath) 9 | 10 | foreign import mkdirRec :: FilePath -> Effect Unit -> Effect Unit 11 | 12 | mkdirRecAff :: FilePath -> Aff Unit 13 | mkdirRecAff dir = makeAff \cb -> do 14 | mkdirRec dir (cb $ Right unit) 15 | pure nonCanceler 16 | -------------------------------------------------------------------------------- /src/Types.purs: -------------------------------------------------------------------------------- 1 | module Types where 2 | 3 | import Prelude 4 | 5 | data RecordLabelStyle 6 | = ArgRecordLabels 7 | | AlphabetRecordLabels 8 | 9 | derive instance eqRecordLabelStyle :: Eq RecordLabelStyle 10 | instance showRecordLabelStyle :: Show RecordLabelStyle where 11 | show = case _ of 12 | ArgRecordLabels -> "ArgRecordLabels" 13 | AlphabetRecordLabels -> "AlphabetRecordLabels" 14 | -------------------------------------------------------------------------------- /src/Version.purs: -------------------------------------------------------------------------------- 1 | module Version where 2 | 3 | versionStr :: String 4 | versionStr = "v0.4.0" 5 | -------------------------------------------------------------------------------- /test/Main.purs: -------------------------------------------------------------------------------- 1 | module Test.Main where 2 | 3 | import Prelude 4 | 5 | import Effect (Effect) 6 | import Effect.Class.Console (log) 7 | 8 | main :: Effect Unit 9 | main = do 10 | log "🍝" 11 | log "You should add some tests." 12 | -------------------------------------------------------------------------------- /tidy-mklens.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const Main = require("./output/Main"); 4 | Main.main(); 5 | --------------------------------------------------------------------------------