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 TemplateHaskell #-} | |
module TH where | |
import Language.Haskell.TH | |
import Control.Monad (replicateM) | |
-- f :: Int -> Int -> Int -> Int | |
-- $(apply 'f n) :: [Int] -> Int | |
applyToList f n = do | |
names <- replicateM n (newName "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 TemplateHaskell #-} | |
module Fib where | |
import Language.Haskell.TH | |
import Language.Haskell.TH.Syntax | |
fib' :: Int -> Int | |
fib' n | |
| n <= 2 = 1 | |
| otherwise = fib' (n - 1) + fib' (n - 2) |
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 System.IO | |
import Prelude hiding (lookup) | |
while test action = do | |
res <- test | |
if res | |
then do action >> while test action | |
else return () | |
copy = while (do {x <- isEOF; return (not x)}) (getLine >>= putStr) |
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 RPN where | |
import Control.Monad | |
import Control.Monad.State | |
type Stack = [Int] | |
type StackState = State Stack | |
push :: Int -> StackState () | |
push n = modify (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
for (var i = 2; i < 22; i++) { | |
$$("#DataGrid1__ctl" + i + "_JS1")[0].selectedIndex = 1; | |
} |
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 RankNTypes #-} | |
module Postfix where | |
import qualified Stack as Stack | |
type Cmd s s' = forall a. s -> (s' -> a) -> a | |
post :: (s -> s') -> Cmd s s' | |
post f s = next (f s) |
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 Data.List (intersperse) | |
padding :: String -> Int -> String | |
padding str n | |
| length str >= n * 2 = str | |
| otherwise = let l = (n * 2 - length str) `div` 2 | |
in replicate l ' ' ++ str ++ replicate l ' ' |
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 Control.Concurrent | |
import Control.Monad | |
import System.Exit | |
data Alarm = Alarm { | |
second :: Int, | |
message :: String | |
} |
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 Arrows #-} | |
module Main where | |
import Control.Arrow | |
import Control.Monad | |
import qualified Control.Category as Cat | |
import Data.List | |
import Data.Maybe | |
import System.Random |
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.Monad | |
type Reciver a = [a] -> IO () | |
type Sender a = [a] | |
sender :: Int -> Sender Int | |
sender n = n : sender (n + 1) | |
printer :: Show a => Reciver a | |
printer = mapM_ print |