Search code examples
packageracketdependent-typetyped-racketraco

How do I run Pie (from The Little Typer) from the command line?


I've been reading The Little Typer for a while now and I want to actually try out Pie now instead of just reading about it. Here are the steps in which I tried to get a Pie REPL up and running in the command line (on a Mac):

brew install racket
raco pkg install -n pie
racket -l pie -i

The last line outputs this:

Welcome to Racket v7.9 [bc].
standard-module-name-resolver: collection not found
  for module path: typed/racket/base
  collection: "typed/racket"
  in collection directories:
   /Users/caspianahlberg/Library/Racket/7.9/collects
   /usr/local/Cellar/minimal-racket/7.9/share/racket/collects
   /usr/local/Cellar/minimal-racket/7.9/share/racket/pkgs/racket-lib
> 

Furthermore, when testing out Pie expressions, like (cons 'foo 'bar), it tells me this:

stdin::1: #%top-interaction: unbound identifier;
 also, no #%app syntax transformer is bound
  at: #%top-interaction
  in: (#%top-interaction cons (quote foo) (quote bar))
  location...:
   stdin::1
  context...:
   /usr/local/Cellar/minimal-racket/7.9/share/racket/collects/racket/repl.rkt:11:26

It seems like something isn't installed correctly when running Pie from the command line. Does anyone who has run into this problem know how to resolve it?


Solution

  • If you are on a Mac, you should install it from https://download.racket-lang.org/ and then launch DrRacket: it has its own IDE. The racket that is called via cli, like you suggested, seems to be a very different beast.

    When you launch DrRacket, it would not know what 'pie' is. You ned to go to File->Package Manager, enter 'pie' as Package Source, and click 'Update' button. It will take some time, but you will have pie on your plate.

    When DrRacket runs, you see two parts in its window: code part and execution part. You can write your code, but make sure you start with #lang pie. You can save that code, by clicking a button showing something that the ancients called "floppy disk". You can click "run" button, and your code will run in the execution part. Some code can be added in the execution part, but no new definitions. definitions go in the code part.