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
(module test-module (quote #%builtin-kernel) | |
(#%plain-module-begin | |
(#%require /libs/racket/base) | |
(#%provide test-result) | |
(#%require /libs/racket/private/syntax-case) | |
(define-syntax defun | |
(#%plain-lambda (stx) | |
(#%plain-app | |
(#%variable-reference console-log) | |
(#%variable-reference stx) |
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
#lang racket | |
(define a 1) | |
(define b 2) | |
; quote | |
'(+ a b) ; '(+ a b) | |
; quasiquote | |
`(+ a ,b) ; '(+ a 2) | |
; nested quasi-quote expr |
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
#lang racket | |
(define-syntax-rule (swap x y) | |
(let ([tmp x]) | |
(set! x y) | |
(set! y tmp))) | |
;; this | |
(let ([tmp 5] | |
[other 6]) | |
(swap tmp other) ;; swap also has a tmp in its body, however it is guaranteed to be a different object |
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
a | a | a | a | a | a |
---|
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
#!/usr/bin/env stack | |
-- stack exec ghc --resolver lts-16.2 --package criterion -- -threaded -O2 -rtsopts -with-rtsopts=-N -eventlog | |
import Control.Monad (replicateM_, void) | |
import Criterion.Main | |
import Data.Foldable (foldl') | |
import Data.Tree | |
treeFoldStrict :: (b -> [a] -> b) -> b -> Tree a -> b | |
treeFoldStrict f init (Node val children) = |
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
#!/usr/bin/env stack | |
-- stack exec ghc --resolver lts-16.2 --package time --package async --package text --package deepseq -- -prof -fprof-auto -threaded -O2 -rtsopts -with-rtsopts=-N -eventlog | |
{- | |
See if we can reproduce having to repeatedly generate environments | |
-} | |
{-# LANGUAGE BangPatterns #-} | |
{-# LANGUAGE NumericUnderscores #-} | |
{-# LANGUAGE RecordWildCards #-} |
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
#!/usr/bin/env stack | |
-- stack script --resolver lts-16.2 --package criterion | |
{-# LANGUAGE NumericUnderscores #-} | |
import Control.Monad (replicateM_, void) | |
import Criterion.Main | |
import Data.Foldable (foldl', foldr) | |
main :: IO () |
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
#!/usr/bin/env stack | |
-- stack script --resolver lts-16.2 --package criterion --package relude --package text --package deepseq | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE NumericUnderscores #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
import Control.DeepSeq (NFData) | |
import Control.Monad (replicateM_, void) | |
import Criterion.Main |
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
#!/usr/bin/env stack | |
-- stack exec ghc --resolver lts-16.2 --package async --package criterion -- -threaded -O2 -rtsopts -with-rtsopts=-N | |
import Control.Concurrent.Async (async, mapConcurrently_) | |
import Control.Monad (replicateM_, void) | |
import Criterion.Main | |
main :: IO () | |
main = defaultMain |
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
{- | | |
DESCRIPTION | |
This program parses valid NRICs from text. | |
NRICs are unique identification numbers given to Singaporeans and Permanent residents of Singapore. | |
SYSTEM | |
This runs on GHC 8.10.1 | |
These libraries should be included with your GHC distribution: |