View adt.rkt
#lang racket
; simple cons pairs
(define (my-cons fst snd)
(λ (f) (f fst snd)))
(define (my-first c)
(c (λ (a b) a)))
(define (my-second c)
View booldef.rkt
(define True (λ () (λ (a b) (a))))
(define False (λ () (λ (a b) (b))))
View simple_alarm.hs
{-# LANGUAGE OverloadedStrings #-}
import Network.MPD
import Control.Concurrent.Timer
import Control.Concurrent.Suspend.Lifted
import System.Environment
startTimer seconds = oneShotTimer (withMPD (play Nothing) >> return ()) (sDelay (fromInteger seconds))
View lisp.py
def tail_rec(fun):
'''
Receive a function `fun` as an argument;
Return a function which accepts `fun` and runs it in a loop.
'''
def tail(fun):
a = fun
while callable(a):
a = a()
return a
View fizzbuzz.hs
{-# LANGUAGE MonadComprehensions #-}
-- From https://bmark.us/bmark/readable/060063d3dd0330
import Data.Monoid ((<>))
import Data.Maybe (fromMaybe)
import Control.Monad (mapM_)
fizzbuzz x = fromMaybe (show x) $ [ "fizz" | x `rem` 3 == 0 ]
<> [ "buzz" | x `rem` 5 == 0 ]
View keepassalong.pl
#!/usr/bin/env perl
use v5.14;
use strict;
use warnings;
use File::KeePass;
use Text::CSV;
use Data::Dump qw(pp);
use Term::ReadPassword;
View free_monad_functor_adt.hs
{-# LANGUAGE RankNTypes #-}
data F f = F {
_map :: forall a b. (a -> b) -> f a -> f b
}
data Mu f a
= Term { retract :: a }
| Cont (f (Mu f a))
View freestream.hs
{- | THIS HAS MOVED
-
- https://github.com/gatlin/FreeStream
-}
View typeops.lhs
Type operators!
===
Turns out a GHC language extension makes a lot of cool things possible that I
think you hinted at:
> {-# LANGUAGE TypeOperators #-}
> data a + b = Inl a | Inr b deriving Show
View id.js
var getId = function() {
var _id = 0;
return function() {
return _id++;
}
}()
// usage
console.log(getId());