Last active
January 13, 2016 12:30
-
-
Save gfldex/d69c79e516b0cf4d1d88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
class Replacement { | |
} | |
use Lib Str; | |
my $g = Guard.new(""); | |
dd $g ~ "abc"; | |
dd "abc" ~ $g; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
role ConcatGuard[::T-right] { | |
has T-right $.attr is rw; | |
method left-type () is nodal { self.WHAT } | |
method right-type () is nodal { T-right } | |
method convert () {...} # --> T-right | |
method new (T-right) {...} | |
} | |
sub EXPORT(::T = Str) { | |
my $t = T; | |
class Example is Mu does ConcatGuard[$t] { | |
method convert(){ | |
$.attr.subst('<','<').subst('&', '&'); | |
} | |
method new($s) { | |
self.bless(attr=>$s.subst('&', '&').subst('<', '<')); | |
} | |
} | |
multi sub infix:<~>(Example \l, T \r){ note "op1"; }; | |
multi sub infix:<~>(T \l, Example \r){ note "op2"; }; | |
{ | |
Guard => Example, | |
'&infix:<~>' => &infix:<~>, | |
# '&infix:<~>' => sub (T \l, Example \r){ l ~ r }, | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment