https://github.com/evhub/point-free-transformer
A point-free implementation of a one-layer transformer in Coconut.
https://github.com/evhub/point-free-transformer
Last synced: about 1 year ago
JSON representation
A point-free implementation of a one-layer transformer in Coconut.
- Host: GitHub
- URL: https://github.com/evhub/point-free-transformer
- Owner: evhub
- License: apache-2.0
- Created: 2022-10-17T01:37:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-18T22:05:32.000Z (over 3 years ago)
- Last Synced: 2025-01-30T01:44:58.603Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 113 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# point-free-transformer
A [point-free](https://en.wikipedia.org/wiki/Tacit_programming) implementation of a one-layer transformer in [Coconut](https://coconut-lang.org/).



See the full highlighted source [here](https://refined-github-html-preview.kidonng.workers.dev/evhub/point-free-transformer/raw/main/point_free_transformer.html).
Some help for those that don't read Coconut:
- `..>` is forward function composition (so `f ..> g` is `g . f` in Haskell)
- `f$()` is partial application (so `f$()` is `functools.partial(f, )` in Python)
- `lift` “lifts” a function so that all of its arguments become unary functions (for a binary function, `lift` is the S' combinator, or `liftA2` in Haskell—e.g. `lift(f)(g, h)` is equivalent to `lambda x: f(g(x), h(x))` in Python)
- `()` is the operator function for `` (so `(+)` is `operator.add` in Python)
- `(. )` is equivalent to `$(?, )` (`?` is a placeholder that means that argument isn't partially applied)
- `.method()` is equivalent to `lambda x: x.method()` in Python
Also, `einsum` here is [`better_einsum.einsum`](https://github.com/evhub/better_einsum).