Merge pull request #7 from bennn/no-colon
[no-colon] re-export bindings without the colon
This commit is contained in:
commit
6d5902db3a
|
@ -2,6 +2,7 @@ trivial
|
||||||
===
|
===
|
||||||
[](https://travis-ci.org/bennn/trivial)
|
[](https://travis-ci.org/bennn/trivial)
|
||||||
[](https://coveralls.io/github/bennn/trivial?branch=master)
|
[](https://coveralls.io/github/bennn/trivial?branch=master)
|
||||||
|
[](http://pkg-build.racket-lang.org/doc/trivial/index.html)
|
||||||
|
|
||||||
This library provides "smarter" versions of Typed Racket standard library functions.
|
This library provides "smarter" versions of Typed Racket standard library functions.
|
||||||
For example:
|
For example:
|
||||||
|
|
7
format/no-colon.rkt
Normal file
7
format/no-colon.rkt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#lang typed/racket/base
|
||||||
|
|
||||||
|
(provide (all-from-out trivial/format))
|
||||||
|
|
||||||
|
(require (rename-in trivial/format
|
||||||
|
[format: format]
|
||||||
|
[printf: printf]))
|
9
math/no-colon.rkt
Normal file
9
math/no-colon.rkt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#lang typed/racket/base
|
||||||
|
|
||||||
|
(provide (all-from-out trivial/math))
|
||||||
|
|
||||||
|
(require (rename-in trivial/math
|
||||||
|
[+: +]
|
||||||
|
[-: -]
|
||||||
|
[*: *]
|
||||||
|
[/: /]))
|
14
no-colon.rkt
Normal file
14
no-colon.rkt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#lang typed/racket/base
|
||||||
|
|
||||||
|
;; Provides the same bindings as `trivial/main`,
|
||||||
|
;; but without the trailing colon.
|
||||||
|
|
||||||
|
(provide
|
||||||
|
(all-from-out trivial/format/no-colon)
|
||||||
|
(all-from-out trivial/math/no-colon)
|
||||||
|
(all-from-out trivial/regexp/no-colon))
|
||||||
|
|
||||||
|
(require
|
||||||
|
trivial/format/no-colon
|
||||||
|
trivial/math/no-colon
|
||||||
|
trivial/regexp/no-colon)
|
|
@ -106,7 +106,7 @@
|
||||||
(define-for-syntax (group-error str reason)
|
(define-for-syntax (group-error str reason)
|
||||||
(raise-argument-error
|
(raise-argument-error
|
||||||
errloc-key
|
errloc-key
|
||||||
(format "Valid regexp pattern (contains unmatched ~a)" reason)
|
(format "Valid regexp pattern (unmatched ~a)" reason)
|
||||||
str))
|
str))
|
||||||
|
|
||||||
;; Dispatch for counting groups
|
;; Dispatch for counting groups
|
||||||
|
|
14
regexp/no-colon.rkt
Normal file
14
regexp/no-colon.rkt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#lang typed/racket/base
|
||||||
|
|
||||||
|
(provide (all-from-out trivial/regexp))
|
||||||
|
|
||||||
|
(require (rename-in trivial/regexp
|
||||||
|
[regexp-match: regexp-match]
|
||||||
|
[regexp: regexp]
|
||||||
|
[pregexp: pregexp]
|
||||||
|
[byte-regexp: byte-regexp]
|
||||||
|
[byte-pregexp: byte-pregexp]
|
||||||
|
[define-regexp: define-regexp]
|
||||||
|
[define-pregexp: define-pregexp]
|
||||||
|
[define-byte-regexp: define-byte-regexp]
|
||||||
|
[define-byte-pregexp: define-byte-pregexp]))
|
|
@ -3,14 +3,17 @@
|
||||||
@require[scribble/eval]
|
@require[scribble/eval]
|
||||||
@require[scriblib/footnote]
|
@require[scriblib/footnote]
|
||||||
|
|
||||||
@title[#:tag "top"]{@bold{Trivial: Solving the easiest type-checking problems}}
|
@title[#:tag "top"]{Trivial: Solving the easiest type-checking problems}
|
||||||
@author[@hyperlink["https://github.com/bennn"]{Ben Greenman}]
|
@author[@hyperlink["https://github.com/bennn"]{Ben Greenman}]
|
||||||
|
|
||||||
@defmodule[trivial]
|
@defmodule[trivial]
|
||||||
@(define trivial-eval (make-base-eval #:lang 'typed/racket/base '(begin (require trivial))))
|
@(define trivial-eval (make-base-eval #:lang 'typed/racket/base '(begin (require trivial))))
|
||||||
|
|
||||||
This library exports a collection of @hyperlink["http://www.greghendershott.com/fear-of-macros/"]{macros} that implement statically-checked interfaces to standard library functions.
|
This library exports a collection of @hyperlink["http://www.greghendershott.com/fear-of-macros/"]{macros} that implement statically-checked interfaces to standard library functions.
|
||||||
All exported macros are named with a trailing colon (meant as a hint that some extra type-checking may happen at the call site).
|
All exported macros are named with a trailing colon (meant as a hint that some extra type-checking may happen at the call site).@note{
|
||||||
|
Not a fan of the colon convention? @racket[trivial/no-colon] provides the same identifiers, colon-free.
|
||||||
|
Same goes for each sub-collection, for instance you can require @racket[trivial/math/no-colon].
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@emph{Hidden Agenda:}
|
@emph{Hidden Agenda:}
|
||||||
|
@ -67,6 +70,7 @@ In other words, the result is one string for the matched substring and an unknow
|
||||||
(U #f (List String String)))
|
(U #f (List String String)))
|
||||||
(ann (regexp-match: #"(la(m*)bda)" #"lam")
|
(ann (regexp-match: #"(la(m*)bda)" #"lam")
|
||||||
(U #f (List Bytes Bytes Bytes)))
|
(U #f (List Bytes Bytes Bytes)))
|
||||||
|
(regexp-match: "(bad))group" "")
|
||||||
]
|
]
|
||||||
|
|
||||||
@emph{Note:} the regular expression @racket{|} operator is not currently supported because it can nullify some groups.
|
@emph{Note:} the regular expression @racket{|} operator is not currently supported because it can nullify some groups.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user