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
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
import Prelude hiding (fst) | |
class Fst a b | a -> b where | |
fst :: a -> b | |
instance Fst (a, b) a where |
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
(function (p) { | |
var arr = []; | |
while (!(function (n) { | |
return (function (p) { | |
return p | |
})(n)(true)(false) | |
})((function (p) { | |
return p(function (x) { | |
return function (y) { | |
return x |
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
{-# LANGUAGE DataKinds, GADTs, TypeOperators, KindSignatures #-} | |
-- http://www.reddit.com/r/haskell/comments/1q93r2/haskell_the_language_most_likely_to_change_the/cdberll | |
data Nat = Z | S Nat deriving (Show) | |
data SNat n where | |
Zero :: SNat Z | |
Succ :: SNat n -> SNat (S n) |
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 Data.Monoid | |
h x = [x] | |
{-- | |
h | |
A ----->[A] | |
\ | | |
\ | |
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
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE ScopedTypeVariables #-} -- for Show | |
data Zero | |
data Succ a | |
data from :-> to | |
data act1 :>> act2 | |
infixr :>> |
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 Parser where | |
import Data.Generics | |
import Data.List.Split (splitOn) | |
import Control.Applicative ((<$>), (<*>)) | |
import Data.Time.Clock.POSIX (posixSecondsToUTCTime) | |
import Data.Time hiding (parseTime) | |
-- A customised version of language-sh is needed | |
import qualified Language.Sh.Parser as P |
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
newtype State s a = State {runS :: s -> (a, s)} | |
instance Monad (State s) where | |
return x = State $ \s -> (x, s) | |
ma >>= f = State $ \s -> let (a, s1) = runS ma s | |
in runS (f a) s1 | |
get = State $ \s -> (s, s) | |
put x = State $ \_ -> ((), x) |
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
toggle_ptrace() { | |
local enable | |
mapfile -t enable < /proc/sys/kernel/yama/ptrace_scope | |
enable=${enable[0]} | |
if [[ $enable == '0' ]]; then | |
enable=1 | |
else | |
enable=0 | |
fi | |
sudo sh -c "echo $enable > /proc/sys/kernel/yama/ptrace_scope" |
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 Control.Applicative ((<$>)) | |
import System.Directory | |
-- Because Hugs doesn't have System.FilePath.(</>) | |
(</>) :: FilePath -> FilePath -> FilePath | |
parent </> child = parent ++ "/" ++ child | |
getDirectoryContents' :: FilePath -> IO [FilePath] | |
getDirectoryContents' dir = | |
filter (`notElem` [".", ".."]) <$> getDirectoryContents dir |
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 Main where | |
import System.IO | |
main = do | |
h1 <- openFile "file1" ReadMode | |
h2 <- openFile "file2" ReadMode | |
h3 <- openFile "file3" AppendMode | |
copy h1 h2 h3 | |
hClose h1 |