https://github.com/jackfirth/compact-annotations
A Typed Racket package for writing compact polymorphic (and non-polymorphic) function annotations with a syntax similar to that of Haskell's type annotations
https://github.com/jackfirth/compact-annotations
Last synced: about 2 months ago
JSON representation
A Typed Racket package for writing compact polymorphic (and non-polymorphic) function annotations with a syntax similar to that of Haskell's type annotations
- Host: GitHub
- URL: https://github.com/jackfirth/compact-annotations
- Owner: jackfirth
- Created: 2014-11-13T08:08:15.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-04T23:12:10.000Z (over 9 years ago)
- Last Synced: 2025-04-10T12:25:04.764Z (about 2 months ago)
- Language: Racket
- Size: 215 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
compact-annotations [](https://travis-ci.org/jackfirth/compact-annotations) [](https://coveralls.io/r/jackfirth/compact-annotations)
===================
[Documentation](http://pkg-build.racket-lang.org/doc/compact-annotations/index.html)A Typed Racket package for writing compact polymorphic (and non-polymorphic) function annotations with a syntax similar to that of Haskell's type annotations.
Examples:
(require compact-annotations)
(:: flip A B => A -> (A -> B) -> B)
(define ((flip v) f)
(f v))
(:: zip-with A B C => (A B -> C) -> (Listof A) (Listof B) -> (Listof C))
(define ((zip-with zipper) as bs)
(map zipper as bs))
(:: compare-as A B => (A A -> Boolean) -> (B -> A) -> B B -> Boolean)
(define (((compare-as base-compare) convert) v1 v2)
(base-compare (convert v1) (convert v2)))(:: string-shorter? String String -> Boolean)
(define string-shorter?
(((inst compare-as Real) <) string-length))(:: in-range? Real Real + Boolean -> Real -> Boolean)
(define ((in-range? low high [include-endpoints? #t]) x)
((if include-endpoints? <= <) low x high))
(:: and? A => * (A -> Boolean) -> A -> Boolean)
(define ((and? . ps) a)
(andmap (λ ([p : (A -> Boolean)]) (p a)) ps))To install, run `raco pkg install compact-annotations`.