Add unpackLiterals proc to patterns module
This commit is contained in:
parent
e65cc5ab9a
commit
1dd197f102
|
@ -15,9 +15,11 @@ when defined(posix):
|
|||
from ./syndicate/relays import Tcp, Unix, connect, connectStdio
|
||||
export Tcp, Unix, connect, connectStdio
|
||||
|
||||
export patterns
|
||||
|
||||
export Actor, Assertion, Facet, Handle, Ref, Symbol, Turn, TurnAction,
|
||||
`$`, addCallback, analyse, asyncCheck, bootDataspace,
|
||||
drop, facet, future, grab, grabLit, inFacet, message, newDataspace, onStop, publish,
|
||||
facet, future, inFacet, message, newDataspace, onStop, publish,
|
||||
retract, replace, run, stop, unembed
|
||||
|
||||
proc `!`*(typ: static typedesc): Pattern {.inline.} =
|
||||
|
|
|
@ -209,6 +209,12 @@ proc grabLit*(): Pattern =
|
|||
proc grabDict*(): Pattern =
|
||||
grabType(dataspacePatterns.DCompoundDict[void])
|
||||
|
||||
proc unpackLiterals*[E](pr: Preserve[E]): Preserve[E] =
|
||||
result = pr
|
||||
apply(result) do (pr: var Preserve[E]):
|
||||
if pr.isRecord("lit", 1):
|
||||
pr = pr.record[0]
|
||||
|
||||
proc inject*(pat: Pattern; bindings: openArray[(int, Pattern)]): Pattern =
|
||||
## Construct a `Pattern` from `pat` with injected overrides from `bindings`.
|
||||
## Injects are made at offsets indexed by the discard (`<_>`) patterns in `pat`.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "20230518"
|
||||
version = "20230530"
|
||||
author = "Emery Hemingway"
|
||||
description = "Syndicated actors for conversational concurrency"
|
||||
license = "Unlicense"
|
||||
|
@ -9,4 +9,4 @@ srcDir = "src"
|
|||
|
||||
# Dependencies
|
||||
|
||||
requires "hashlib", "nim >= 1.4.8", "preserves >= 20221208", "taps >= 20221119"
|
||||
requires "hashlib", "nim >= 1.4.8", "preserves >= 20230530", "taps >= 20221119"
|
||||
|
|
Loading…
Reference in New Issue