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 --resolver lts-9.21 script | |
--package shelly --package text | |
-} | |
{-# OPTIONS_GHC -Wall -Werror #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE ExtendedDefaultRules #-} | |
{-# OPTIONS_GHC -fno-warn-type-defaults #-} | |
import Shelly |
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 --resolver lts-9.21 script --package loch-th | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# OPTIONS_GHC -Wall -Werror #-} | |
import Debug.Trace.LocationTH (check) | |
import System.Environment (getArgs) | |
main :: IO () | |
main = do |
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 --resolver lts-11.2 script | |
{-# OPTIONS_GHC -Wall -W -Werror #-} | |
data Foo = Foo | |
{ fooInt :: Int | |
, fooBar :: Bar | |
} deriving Show | |
data Bar = Bar Baz |
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
{-# OPTIONS_GHC -Wall -Werror #-} | |
module DaPhone where | |
import Data.Char (isUpper, toLower) | |
import Data.List (elemIndex, foldl', intersperse) | |
import Data.Maybe (catMaybes) | |
data DaPhone = DaPhone [String] | |
deriving (Eq, Show) |
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 Data.Foldable (foldl') | |
import Debug.Trace (trace) | |
prnEqual :: (Eq a) => a -> a -> IO () | |
prnEqual a b = if a == b then print "True" else print "False" | |
-- Note the absence of parentheses around `Eq a` and having exactly one `print`. | |
prnEqual' :: Eq a => a -> a -> IO () | |
prnEqual' a b = print $ if a == b then "True" else "False" |
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
{-- XXX Your definition of `checkChar` is okay, but the abstraction itself | |
-- is very odd. It is fine as an exercise of using "do" notation and | |
-- `return`. In real code though explicit statements are both short and | |
-- expressive (see lines 21-22). | |
checkChar :: IO Bool | |
checkChar = do | |
c <- getChar | |
return (c == 'y') | |
--} |
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
listsum :: Num a => [a] -> a | |
listsum [] = 0 | |
listsum (x:xs) = x + listsum xs | |
main :: IO () | |
main = print $ listsum [1..5] |
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 GADTs #-} | |
module Program where | |
-- | |
-- The Operational Monad Tutorial: | |
-- http://apfelmus.nfshost.com/articles/operational-monad.html | |
-- | |
-- GADT | |
data Program instr a where | |
Then :: instr a -> (a -> Program instr b) -> Program instr 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
$ cat noexit.sh | |
#!/bin/sh | |
seq 100 | while read; do exit; done # If `exit' terminated the script .. | |
echo 'Still alive!' # .. this message would not be printed. | |
$ | |
$ sh noexit.sh | |
Still alive! |
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
#!/bin/sh | |
set -eu | |
M0UT=ut/.libs/lt-m0ut | |
[ -x $M0UT ] || { echo "$M0UT: No such file" >&2; exit 1; } | |
CORE=$(sudo ls -t $(sudo find /var/mero -type f -name core.\*) | head -1) | |
sudo gdb -nx -c $CORE $M0UT <<EOF | |
set pagination off |
NewerOlder