Skip to content

Instantly share code, notes, and snippets.

View jackfirth's full-sized avatar

Jack Firth jackfirth

View GitHub Profile
@jackfirth
jackfirth / packages.md
Last active December 11, 2015 22:48
Summary of thoughts on extensions to, implementations of, ideas about, and protocols surrounding Racket package catalogs

Exposition

A package catalog is something that maps package names to package metadata which must include a package source. This decouples the name of a package from where it's source is located, allowing package authors to declare dependencies on names instead of sources and to relocate the source of their package without breaking the dependency specifications of client packages.

Package metadata must include a checksum, but other than that no keys are required for a properly operating package catalog. However many tools (particularly raco pkg) use certain

@jackfirth
jackfirth / stuff-to-do.md
Last active February 12, 2016 00:50
Racket things to make

Racket projects

Racket is a language with a small community and a big space of things you can do. This means there's a lot of incredibly useful libraries and tools that nobody's had the time to make. This gist is a catalog of things I'd like to see made, maybe with the eventual goal of figuring out a way to coordinate with other community members in getting some of them done.

  • More contract helpers like predicate/c. Here are some possibilities:
    • (list-repeating/c number? boolean? string?) - describes lists like (1 #t "foo") and (1 #t "foo" 2 #f "bar")
    • (operation-> string?) - describes functions like string-append that take any number of string?s and returns a string?. (no idea what to name)
    • (rest-> string? number?) - All arguments are string?s, result is number?. (no idea what to name)
    • More ideas in unstable/contract
  • Better http libraries
  • Use xrepl when developing outside DrRacket. Set to automatically start up whenever racket is run at command line.
  • racket-mode for emacs development
  • #lang envy for environment variable configuration
  • #lang debug for "printf debugging"
  • #lang sweet-exp for prettifying requires and provides, or other simple pieces of code where parens are just noise (can be partially used in a file, doesn't need to apply to the whole file)
  • #lang reprovide for modules that just require and provide other modules to group them together
  • Use #lang racket/base instead of #lang racket for libraries, packages, and other re-usable pieces of code, to reduce dependencies
  • Use the -lib packages of libraries for applications to reduce dependencies
  • When designing libraries, avoid documenting and exposing subcollections to allow more flexibility for the library's code to shift around
  • When designing libraries, stick non-exposed modules into a /private subcollection to make any code depending on internals sti
@jackfirth
jackfirth / 12-packages.md
Last active December 20, 2016 21:05
Potential list of packages to blog about for a 12 Days of Racket Packages series
  • envy
  • fra
  • gregor
  • quickcheck
  • fancy-app
  • threading
  • rackjure
  • ragg
  • reprovide-lang
  • sweet-exp
@jackfirth
jackfirth / addpath
Last active June 14, 2018 21:10
Shell script to automatically add something to the PATH environment variable in your shell profile, defaulting to current directory and ~/.profile
#! /usr/bin/env racket
#lang racket/base
(require racket/file
racket/function
racket/cmdline)
(define (add-path-to-bash-profile! #:path path-string
#:profile profile-path-string)

12 Days of Racket Packages - flexpr

Welcome to 12 Days of Racket Packages! The Racket Package Catalog contains 695 packages at the time of this writing (counting packages in the main distribution). That's a pretty big achievement for such a small community and a package system that's barely two years old. In hopes of helping users find great packages, we're publishing a series of 12 blog posts, once per day, starting today. Each post will detail a single package available in the catalog and describe what you might use it for and what's interesting about it. Extra attention may be paid to "Rackety" features, for instance packages providing a custom #lang. This series is in the spirit of and directly inspired by 24 Days of Hackage.

The flexpr package (source) by Greg Hendershott is a simple package

@defproc[(specification [prop property?] [arb arbitrary?] ...) specification?]{
Constructs a runnable, executable, testable @specification-tech[] that tests that
@racket[prop] holds for all inputs from the given @racket[arb]s. The returned
specification can be quickly tested with @racket[check-specification]. Additionally,
the specification can be run and have its results analyzed separately by using
@racket[run-specification].
@quickcheck2-examples[
(check-specification (specification positive? arbitrary-natural))
(check-specification (specification even? arbitrary-natural))
]}
@jackfirth
jackfirth / grammar.rkt
Created October 29, 2015 16:42
Fooling around with grammar definition syntaxes
(define (zero-or-more term)
(one-of term
(sequence-of term (zero-or-more term))))
(define nat-addition-grammar
(grammar [NUMBER (one-of DIGIT
(sequence-of NONZERO-DIGIT (zero-or-more DIGIT)))]
[DIGIT (one-of NONZERO-DIGIT
(literal 0))]
[NONZERO-DIGIT (one-of (literal 1) (literal 2) (literal 3) (literal 4) (literal 5) (literal 6) (literal 7) (literal 8) (literal 9))]

What is the type of a value that promises the following:

  1. It is a struct instance
  2. It has a certain struct property
  3. That struct property has certain restrictions on its value