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
{-# language MultiWayIf #-} | |
module MultiWayIfExample where | |
withoutExtension n = | |
if n < 10 | |
then 'a' | |
else | |
if n < 100 | |
then 'b' |
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
{-# language LinearTypes #-} | |
module LinearExample where | |
id :: a ⊸ a | |
id 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
{-# language | |
GADTSyntax, | |
FlexibleInstances | |
#-} | |
import Prelude hiding (String) | |
import qualified Prelude | |
main :: IO () | |
main = print sample |
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
import System.CPUTime (getCPUTime) | |
main :: IO () | |
main = | |
do | |
timeStart <- getCPUTime | |
print expensiveComputation | |
timeEnd <- getCPUTime | |
print $ (fromInteger $ timeEnd - timeStart) / (fromInteger $ 10 ^ 12) |
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
fn cartesian_product(scale: &mut (u32, u32)) -> Vec<(u32, u32)> { | |
(0..5) | |
.flat_map(|a| (0..5).map(|b| (a * scale.0, b * scale.1))) | |
.collect() | |
} | |
// error[E0373]: closure may outlive the current function, but it borrows `a`, which is owned by the current function | |
// --> src/main.rs:7:34 | |
// | | |
// 7 | .flat_map(|a| (0..5).map(|b| (a * scale.0, b * scale.1))) |
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
fn cartesian_product(scale: &mut (u32, u32)) -> Vec<(u32, u32)> { | |
(0..5) | |
.flat_map(|a| (0..5).map(|b| (a * scale.0, b * scale.1))) | |
.collect() | |
} | |
// error[E0373]: closure may outlive the current function, but it borrows `a`, which is owned by the current function | |
// --> src/main.rs:7:34 | |
// | | |
// 7 | .flat_map(|a| (0..5).map(|b| (a * scale.0, b * scale.1))) |
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
I: Reset h0: DEF "<" 2 122 | |
P: 1 h1: DEF "|" 2 52 | |
h2: DEF "if" 3 132 | |
h3: DEF "*" 2 92 | |
h4: DEF "not" 1 38 | |
h5: DEF "false" 0 26 | |
h6: DEF "-" 2 82 | |
h7: DEF "+" 2 72 | |
h8: DEF "main" 0 4 | |
h9: DEF "true" 0 32 |
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
fromList | |
[ | |
("main",(0,4)), | |
("a",(0,14)), | |
("b",(0,20)), | |
("false",(0,26)), | |
("true",(0,32)), | |
("not",(1,38)), | |
("negate",(1,45)), | |
("|",(2,52)), |
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
main = a + b; a = 0; b = 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
I: Reset h0: DEF "<" 2 120 | |
P: 1 h1: DEF "|" 2 50 | |
h2: DEF "if" 3 130 | |
h3: DEF "*" 2 90 | |
h4: DEF "not" 1 36 | |
h5: DEF "false" 0 24 | |
h6: DEF "-" 2 80 | |
h7: DEF "+" 2 70 | |
h8: DEF "main" 0 4 | |
h9: DEF "true" 0 30 |