recursion-schemes
regex
recursion-schemes | regex | |
---|---|---|
20 | 91 | |
335 | 3,355 | |
0.3% | 1.4% | |
4.3 | 8.9 | |
19 days ago | 12 days ago | |
Haskell | Rust | |
BSD 2-clause "Simplified" License | Apache License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
recursion-schemes
-
-❄️- 2023 Day 4 Solutions -❄️-
Reasonably proud of my part 2 solution, although would like to try using a recursion scheme rather than unstructured recursion:
-
Interactive animations
Yeah, that project is pretty much at the bottom of my list, unfortunately. My top projects these days are mgmt, klister, recursion-schemes, and hint... And that's already too much!
-
Science of Recursion
In a programming context, recursion schemes can be used to write recursive (or corecursive) functions, by automating/abstracting away the common boilerplate part of actually doing the recursion. They take the form of polymorphic higher-order functions, which can be imported from a library like this classic one.
-
Is there a way to avoid call overhead?
Maybe I didn't link the best post. It is unfortunately the only one I know that uses Rust. If you are able to read Haskell, the documentation for the recursion-schemes package might be a better resource?
-
Ah yes I love arrays with a length of infinity!!!
Writing something as a type of fold over an infinite sequence is nicer than using recursion directly in my opinion. See: https://hackage.haskell.org/package/recursion-schemes
-
Tips on mastering recursion and trees and shit?
Consider recursion schemes! It let's you separate the logic of how your recursion is structured on your data, and the logic of what you're doing on each recursion stage. So e.g. you can write the core logic of a recursive linked list summation as just fun x accum -> x + accum, and then you just find the appropriate recursion scheme to pipe the list values into x and handle recursing to build accum (a catamorphism in this case)
-
So you come across an undocumented library…
It's a pretty complicated bug, documented in details at https://github.com/recursion-schemes/recursion-schemes/issues/50
-
Beautiful ideas in programming: generators and continuations
It’s also trivial and easy in Haskell — you just need an instance of `Foldable` or `Traversable` on your collection, and then you can fold or traverse it in a configurable way. Or for recursive structures, use https://hackage.haskell.org/package/recursion-schemes. Or even just pass a traversal function as an argument for maximum flexibility.
-
fromMaybe is Just a fold
https://hackage.haskell.org/package/recursion-schemes is the "normal" library for this type of generalized folding. It even contains Base instances for Maybe and Either.
-
Annotation via anamorphism?
I've been working on a system which uses recursion-schemes to annotate a recursive type. The annotated tree itself is pretty simple; at each level, we pair the annotation with the base functor, or
regex
-
Zed is now open source
The homepage has a benchmark that compares Zed's "insertion latency" to other editors, and this is the description:
> Open input.rs at the end of line 21 in rust-lang/regex. Type z 10 times, measure how long it takes for each z to display since hitting the z key.
Could someone clarify what that means? My interpretation of that was to go to https://github.com/rust-lang/regex/blob/master/regex-cli/arg... and start typing 'z' at the end of line 21, but that doesn't seem to make any sense. I guess that repo got refactored and those instructions are out of date?
-
CryptoFlow: Building a secure and scalable system with Axum and SvelteKit - Part 3
We also used the avenue to sluggify the question title. We used regex to fish out and replace all occurrences of punctuation and symbol characters with an empty string and using the itertools crate, we joined the words back together into a single string, where each word is separated by a hyphen ("-").
-
Command Line Rust is a great book
Command-Line Rust taught me how to use crates like clap, assert_cmd, and regex. I felt lost before because I didn't know about Rust's ecosystem--which is arguably as important as the language itself. Also, looking up and comparing libraries is a tiring task! blessed.rs is nice but Command-Line Rust really saved me from analysis paralysis.
-
Common Rust Lifetime Misconceptions
burntsushi actually regrets making regex replace return a Cow: https://github.com/rust-lang/regex/issues/676#issuecomment-6.... I’m glad it does, and wish it took an impl Into> there, for the reasons discussed in the issue, but burntsushi has a lot more experience of the practical outcomes of this. Just something more to think about.
-
Advent of Code 2023 is nigh
I'm not familiar with the AoC problem. You might be able to. But RegexSet doesn't give you match offsets.
You can drop down to regex-automata, which does let you do multi-regex search and it will tell you which patterns match[1]. The docs have an example of a simple lexer[2]. But... that will only give you non-overlapping matches.
You can drop down to an even lower level of abstraction and get multi-pattern overlapping matches[3], but it's awkward. The comment there explains that I had initially tried to provide a higher level API for it, but was unsure of what the semantics should be. Getting the starting position in particular is a bit of a wrinkle.
[1]: https://docs.rs/regex-automata/latest/regex_automata/meta/in...
[2]: https://docs.rs/regex-automata/latest/regex_automata/meta/st...
[3]: https://github.com/rust-lang/regex/blob/837fd85e79fac2a4ea64...
-
Text Showdown: Gap Buffers vs. Ropes
It’s not quite that simple, but folks are working on it.
https://github.com/rust-lang/regex/issues/425#issuecomment-1...
https://github.com/helix-editor/helix/pull/211#issuecomment-...
- Please ask questions (rust-lang/regex)
-
ScripterC - Rust-lang set
Dependencies used: - regex - unicode_reader - rust decimal - tokio
-
Regex Engine Internals as a Library
https://www.cs.princeton.edu/courses/archive/fall19/cos226/l... and https://kean.blog/post/lets-build-regex are excellent introductions to implementing a (very) simplified regex engine: construct a nondetermistic finite state automaton for the regex, then perform a graph search on the resulting digraph; if the vertex corresponding to your end state is reachable, you have a match.
I think this exercise is valuable for anyone writing regexes to not only understand that there's less magic than one might think, but also to visualize a bunch of balls bouncing along an NFA - that bug you inevitably hit in production due to catastrophic backtracking now takes on a physical meaning!
Separately re: the OP, https://github.com/rust-lang/regex/issues/822 (and specifically BurntSushi's comment at the very end of the issue) adds really useful context to the paragraph in the OP about niche APIs: https://blog.burntsushi.net/regex-internals/#problem-request... - searching with multiple regexes simultaneously against a text is both incredibly complex and incredibly useful, and I can't wait to see what the community comes up with for this pattern!
What are some alternatives?
distributed-process-platform - DEPRECATED (Cloud Haskell Platform) in favor of distributed-process-extras, distributed-process-async, distributed-process-client-server, distributed-process-registry, distributed-process-supervisor, distributed-process-task and distributed-process-execution
re2 - modern regular expression syntax everywhere with a painless upgrade path [Moved to: https://github.com/SonOfLilit/kleenexp]
record - Anonymous records
node-re2 - node.js bindings for RE2: fast, safe alternative to backtracking regular expression engines.
unliftio - The MonadUnliftIO typeclass for unlifting monads to IO
zig - General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
machines - Networks of composable stream transducers
ngrams - (Read-only) Generate n-grams
chr-core - Constraint Handling Rules
regex-benchmark - It's just a simple regex benchmark of different programming languages.
pipes-core - Compositional pipelines
whatlang-rs - Natural language detection library for Rust. Try demo online: https://whatlang.org/