apply/2
apply/3
cond/1
destructure/2
exit/1
if/2
in/2
match?/2
This file contains hidden or 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
Hello, my name ist {{name}} and I am {{age}} years old. |
This file contains hidden or 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
module DefaultSuperclass | |
data Identity' i = Id' i | |
class Functor' (f : Type -> Type) where | |
map' : (a -> b) -> f a -> f b | |
class Functor' f => Applicative' (f : Type -> Type) where | |
instance Functor' f where | |
map' = ap' . pure' |
Find it here: https://github.com/bitemyapp/learnhaskell
This gist has been upgraded to a blog post here.
This post also appears on lisper.in.
Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.
Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):
The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.
This file contains hidden or 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
sub trait_mod:<is>(&c, :$curried!) { | |
my $arity = &c.arity; | |
&c.wrap(-> |args { | |
args.list.elems == $arity | |
?? callsame() | |
!! &c.assuming(|args) | |
}); | |
} | |
sub foo($a, $b) is curried { |
This file contains hidden or 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
import scalaz._ | |
// A right Kan extension of `F` along itself, constrained by `C`. | |
trait RCodensity[C[_], F[_], A] { | |
def apply[R:C](k: A => F[R]): F[R] | |
} | |
object RCodensity { | |
implicit def codensityMonad[C[_], F[_]]: Monad[({type f[x] = RCodensity[C,F,x]})#f] = | |
new Monad[({type f[x] = RCodensity[C,F,x]})#f] { |
This file contains hidden or 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
module LoobVerifiedMonoid | |
data Loob = Eurt | Eslaf | |
instance Semigroup Loob where | |
Eurt <+> _ = Eurt | |
Eslaf <+> r = r | |
instance Monoid Loob where | |
neutral = Eslaf |
This file contains hidden or 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; | |
sub t ($x, $y, :$label = 'sum') { | |
say "$label: ", $x + $y; | |
} | |
sub namecall(&c, *@pos, *%named is rw) { | |
my %name-to-idx; | |
for &c.signature.params.kv -> $idx, $p { | |
next if $p.named; |