Installation¶
Not on CPAN
There is an unrelated module named Typist on CPAN — it is not this project. This Typist is distributed exclusively via its GitHub repository.
Prerequisites¶
- Perl 5.40 or later.
- cpanm (recommended for installation).
All other dependencies (PPI, JSON::PP) are resolved automatically.
Install¶
cpanm (recommended)¶
This installs the Typist module, along with the typist-check and typist-lsp CLI tools.
Local install (per-project)¶
If you prefer to install into a project-local directory:
Then run your scripts with the local library path:
Carton¶
Add to your cpanfile:
Then:
Note
Since Typist is not on CPAN, carton install alone cannot resolve it. Install Typist with cpanm first, then Carton will recognize it in local/.
From source¶
git clone https://github.com/cwd-k2/typist.git
cd typist
perl Makefile.PL
make && make test
make install
Verify¶
After installation, confirm that Typist is working:
Check that the CLI tools are available:
If you used -L local, use the full paths instead:
Project Setup¶
A typical Typist project looks like this:
my-project/
lib/
MyApp/
Types.pm # Type definitions (typedef, struct, effect, ...)
Logic.pm # Business logic with :sig() annotations
script/
app.pl # Entry point
cpanfile # Dependencies
Your cpanfile:
Your type definitions module (lib/MyApp/Types.pm):
package MyApp::Types;
use v5.40;
use Typist;
use Exporter 'import';
our @EXPORT = qw(Name Email);
BEGIN {
newtype Name => 'Str';
newtype Email => 'Str';
struct User => (
name => 'Name',
email => 'Email',
);
}
1;
Your application code (lib/MyApp/Logic.pm):
package MyApp::Logic;
use v5.40;
use Typist;
use MyApp::Types;
sub greet :sig((User) -> Str) ($user) {
"Hello, " . $user->name . "!";
}
1;
Static Analysis¶
Run typist-check against your project:
typist-check # Scans lib/ by default
typist-check lib/MyApp/Logic.pm # Check specific files
typist-check --verbose # Show clean files too
See typist-check CLI for the full option reference.
Next Steps¶
With everything installed, proceed to First Program to walk through a complete typed program step by step.