Skip to content

Commit

Permalink
fix for 1.6+, clean up operators
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Mar 27, 2022
1 parent 796e22a commit 119020b
Show file tree
Hide file tree
Showing 11 changed files with 651 additions and 483 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ proc map[T](s: seq[T], f: ApplicateArg): seq[T] =
for i in 0..<s.len:
let x = s[i]
result[i] = f.apply(x)
# optional operators (couldnt decide on anything):
result[i] = f | x
result[i] = x |< f # accepts multiple arguments like (1, 2) |< f
result[i] = x |> f # does not do above, and injects x into right hand side
# optional operators:
result[i] = x |> f # injects x into right hand side
result[i] = \f(x)
result[i] = \x.f
result[i] = f(x) # when experimental callOperator is enabled
Expand All @@ -27,8 +25,7 @@ proc map[T](s: seq[T], f: ApplicateArg): seq[T] =
doAssert @[1, 2, 3, 4, 5].map(applicate do (x): x - 1) == @[0, 1, 2, 3, 4]
doAssert @[1, 2, 3, 4, 5].map(fromSymbol(succ)) == @[2, 3, 4, 5, 6]
# optional operators:
doAssert @[1, 2, 3, 4, 5].map(x !=> x * 2) == @[2, 4, 6, 8, 10]
doAssert @[1, 2, 3, 4, 5].map(x \=> x * 2) == @[2, 4, 6, 8, 10]
doAssert @[1, 2, 3, 4, 5].map(x ==> x * 2) == @[2, 4, 6, 8, 10]
```

See tests for more example uses of this library. Tests are ran for multiple backends.
Expand Down
2 changes: 1 addition & 1 deletion applicates.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.3.0"
version = "0.3.1"
author = "metagn"
description = "instantiated \"pointers\" to cached AST"
license = "MIT"
Expand Down
402 changes: 226 additions & 176 deletions docs/applicates.html

Large diffs are not rendered by default.

145 changes: 84 additions & 61 deletions docs/internals.html

Large diffs are not rendered by default.

120 changes: 116 additions & 4 deletions docs/nimdoc.out.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Modified by Boyd Greenfield and narimiran
--primary-background: #fff;
--secondary-background: ghostwhite;
--third-background: #e8e8e8;
--info-background: #50c050;
--warning-background: #c0a000;
--error-background: #e04040;
--border: #dde;
--text: #222;
--anchor: #07b;
Expand All @@ -32,13 +35,18 @@ Modified by Boyd Greenfield and narimiran
--escapeSequence: #c4891b;
--number: #252dbe;
--literal: #a4255b;
--program: #6060c0;
--option: #508000;
--raw-data: #a4255b;
}

[data-theme="dark"] {
--primary-background: #171921;
--secondary-background: #1e202a;
--third-background: #2b2e3b;
--info-background: #008000;
--warning-background: #807000;
--error-background: #c03000;
--border: #0e1014;
--text: #fff;
--anchor: #8be9fd;
Expand All @@ -57,6 +65,8 @@ Modified by Boyd Greenfield and narimiran
--escapeSequence: #bd93f9;
--number: #bd93f9;
--literal: #f1fa8c;
--program: #9090c0;
--option: #90b010;
--raw-data: #8be9fd;
}

Expand Down Expand Up @@ -224,6 +234,12 @@ select:focus {
}

/* Docgen styles */

:target {
border: 2px solid #B5651D;
border-style: dotted;
}

/* Links */
a {
color: var(--anchor);
Expand Down Expand Up @@ -378,6 +394,7 @@ h2 {
margin-top: 2em; }

h2.subtitle {
margin-top: 0em;
text-align: center; }

h3 {
Expand Down Expand Up @@ -491,6 +508,45 @@ hr {
border: 0;
border-top: 1px solid #aaa; }

hr.footnote {
width: 25%;
border-top: 0.15em solid #999;
margin-bottom: 0.15em;
margin-top: 0.15em;
}
div.footnote-group {
margin-left: 1em; }
div.footnote-label {
display: inline-block;
min-width: 1.7em;
}

div.option-list {
border: 0.1em solid var(--border);
}
div.option-list-item {
padding-left: 12em;
padding-right: 0;
padding-bottom: 0.3em;
padding-top: 0.3em;
}
div.odd {
background-color: var(--secondary-background);
}
div.option-list-label {
margin-left: -11.5em;
margin-right: 0em;
min-width: 11.5em;
display: inline-block;
vertical-align: top;
}
div.option-list-description {
width: calc(100% - 1em);
padding-left: 1em;
padding-right: 0;
display: inline-block;
}

blockquote {
font-size: 0.9em;
font-style: italic;
Expand All @@ -499,7 +555,7 @@ blockquote {
border-left: 5px solid #bbc;
}

.pre {
.pre, span.tok {
font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace;
font-weight: 500;
font-size: 0.85em;
Expand All @@ -510,6 +566,12 @@ blockquote {
border-radius: 4px;
}

span.tok {
border: 1px solid #808080;
padding-bottom: 0.1em;
margin-right: 0.2em;
}

pre {
font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace;
color: var(--text);
Expand Down Expand Up @@ -561,6 +623,7 @@ table.line-nums-table {
.line-nums-table td.blob-line-nums pre {
color: #b0b0b0;
-webkit-filter: opacity(75%);
filter: opacity(75%);
text-align: right;
border-color: transparent;
background-color: transparent;
Expand Down Expand Up @@ -609,6 +672,34 @@ table.borderless td, table.borderless th {
The right padding separates the table cells. */
padding: 0 0.5em 0 0 !important; }

.admonition {
padding: 0.3em;
background-color: var(--secondary-background);
border-left: 0.4em solid #7f7f84;
margin-bottom: 0.5em;
-webkit-box-shadow: 0 5px 8px -6px rgba(0,0,0,.2);
-moz-box-shadow: 0 5px 8px -6px rgba(0,0,0,.2);
box-shadow: 0 5px 8px -6px rgba(0,0,0,.2);
}
.admonition-info {
border-color: var(--info-background);
}
.admonition-info-text {
color: var(--info-background);
}
.admonition-warning {
border-color: var(--warning-background);
}
.admonition-warning-text {
color: var(--warning-background);
}
.admonition-error {
border-color: var(--error-background);
}
.admonition-error-text {
color: var(--error-background);
}

.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 !important; }
Expand Down Expand Up @@ -768,9 +859,6 @@ span.classifier {
span.classifier-delimiter {
font-weight: bold; }

span.option {
white-space: nowrap; }

span.problematic {
color: #b30000; }

Expand Down Expand Up @@ -850,6 +938,29 @@ span.Preprocessor {
span.Directive {
color: #252dbe; }

span.option {
font-weight: bold;
font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace;
color: var(--option);
}

span.Prompt {
font-weight: bold;
color: red; }

span.ProgramOutput {
font-weight: bold;
color: #808080; }

span.program {
font-weight: bold;
color: var(--program);
text-decoration: underline;
text-decoration-color: var(--hint);
text-decoration-thickness: 0.05em;
text-underline-offset: 0.15em;
}

span.Command, span.Rule, span.Hyperlink, span.Label, span.Reference,
span.Other {
color: var(--other); }
Expand All @@ -872,6 +983,7 @@ dt pre > span.Operator ~ span.Identifier, dt pre > span.Other ~ span.Identifier
background-position: 0 0;
background-size: 51px 14px;
-webkit-filter: opacity(50%);
filter: opacity(50%);
background-repeat: no-repeat;
background-image: var(--nim-sprite-base64);
margin-bottom: 5px; }
Expand Down
Loading

0 comments on commit 119020b

Please sign in to comment.