diff --git a/README.md b/README.md index 6d2a4d7..16deb5d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ trivial === [![Build Status](https://travis-ci.org/bennn/trivial.svg)](https://travis-ci.org/bennn/trivial) [![Coverage Status](https://coveralls.io/repos/bennn/trivial/badge.svg?branch=master&service=github)](https://coveralls.io/github/bennn/trivial?branch=master) +[![Scribble](https://img.shields.io/badge/Docs-Scribble-blue.svg)](http://pkg-build.racket-lang.org/doc/trivial/index.html) This library provides "smarter" versions of Typed Racket standard library functions. For example: diff --git a/format/no-colon.rkt b/format/no-colon.rkt new file mode 100644 index 0000000..bda290b --- /dev/null +++ b/format/no-colon.rkt @@ -0,0 +1,7 @@ +#lang typed/racket/base + +(provide (all-from-out trivial/format)) + +(require (rename-in trivial/format + [format: format] + [printf: printf])) diff --git a/math/no-colon.rkt b/math/no-colon.rkt new file mode 100644 index 0000000..fba3512 --- /dev/null +++ b/math/no-colon.rkt @@ -0,0 +1,9 @@ +#lang typed/racket/base + +(provide (all-from-out trivial/math)) + +(require (rename-in trivial/math + [+: +] + [-: -] + [*: *] + [/: /])) diff --git a/no-colon.rkt b/no-colon.rkt new file mode 100644 index 0000000..d0392c9 --- /dev/null +++ b/no-colon.rkt @@ -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) diff --git a/regexp.rkt b/regexp.rkt index 1d585b7..5eda021 100644 --- a/regexp.rkt +++ b/regexp.rkt @@ -106,7 +106,7 @@ (define-for-syntax (group-error str reason) (raise-argument-error errloc-key - (format "Valid regexp pattern (contains unmatched ~a)" reason) + (format "Valid regexp pattern (unmatched ~a)" reason) str)) ;; Dispatch for counting groups diff --git a/regexp/no-colon.rkt b/regexp/no-colon.rkt new file mode 100644 index 0000000..b0bdfe5 --- /dev/null +++ b/regexp/no-colon.rkt @@ -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])) diff --git a/scribblings/trivial.scrbl b/scribblings/trivial.scrbl index 10f7773..333b5e4 100644 --- a/scribblings/trivial.scrbl +++ b/scribblings/trivial.scrbl @@ -3,14 +3,17 @@ @require[scribble/eval] @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}] @defmodule[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. -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:} @@ -67,6 +70,7 @@ In other words, the result is one string for the matched substring and an unknow (U #f (List String String))) (ann (regexp-match: #"(la(m*)bda)" #"lam") (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.