Skip to content

Instantly share code, notes, and snippets.

@FCO
Last active November 21, 2018 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FCO/8badb8ffc1ff86a2c2c4ae7963f37fd2 to your computer and use it in GitHub Desktop.
Save FCO/8badb8ffc1ff86a2c2c4ae7963f37fd2 to your computer and use it in GitHub Desktop.
Red Schema
class Bla {
has Ble $.ble;
has Bli $.bli;
}
class Ble {
has Bla $.bla;
has Bli $.bli;
}
class Bli {
has Bla $.bla;
has Ble $.ble;
}
use lib ".";
use Schema <Bla Ble Bli>;
say Bla;
say Ble;
say Bli
sub get-code($name) {
$*REPO.repo-chain.first(*.resolve: CompUnit::DependencySpecification.new: :short-name($name)).prefix.add("{$name}.pm6").slurp
}
sub EXPORT(*@types --> Hash()) {
my @code;
for @types -> $type {
@code.unshift: "class $type \{ ... }";
@code.push: get-code $type;
}
@code.join("\n").EVAL;
@types.map: -> $type { $type => $type.EVAL }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment