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 DeriveGeneric, DataKinds, KindSignatures #-} | |
import GHC.TypeLits | |
import Data.Text (Text) | |
import GHC.Generics (Generic) | |
data Field (n :: Symbol) v = Field v | |
data Value t = Value t | |
data Banana = Banana | |
{ shape :: Field "banana-shape" (Value Text) |
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 TemplateHaskell #-} | |
import System.Environment (getArgs) | |
import Control.Monad (mapM) | |
import Text.PrettyPrint.Mainland | |
import qualified Data.ByteString.Char8 as B | |
import qualified Language.C.Syntax as C | |
import qualified Language.C.Parser as P | |
import Data.Loc | |
import Language.Haskell.TH | |
import Foreign.Ptr |
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 CPP #-} | |
import Distribution.Simple | |
import Distribution.Simple.Configure | |
import System.Directory | |
import System.Cmd | |
import Distribution.Simple | |
import Control.Monad (when) |
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 TemplateHaskell #-} | |
module Rect (Rect, x, y, rect) where | |
import Control.Lens | |
import Data.Functor | |
data Rect = Rect { _x :: Int, _y :: Int } | |
makeLenses ''Rect |
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 RankNTypes #-} | |
import Control.Concurrent | |
import Control.Monad.Fix | |
import Control.Monad.IO.Class | |
import Control.Wire.Core | |
import Control.Wire.Session | |
import Data.Functor.Identity | |
import System.IO | |
import Control.Wire | |
import Prelude hiding ((.), id) |
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
-- http://www.macosxautomation.com/applescript/sbrt/sbrt-09.html | |
on write_to_file(this_data, target_file, append_data) | |
try | |
set the target_file to the target_file as string | |
set the open_target_file to open for access file target_file with write permission | |
if append_data is false then set eof of the open_target_file to 0 | |
write this_data to the open_target_file starting at eof | |
close access the open_target_file | |
return true | |
on error |
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 Foo where | |
data Foo = Foo { name :: NSString, age :: NSNumber } | |
dothing :: Foo -> NSString | |
dothing x = do | |
n <- name x | |
a <- age x | |
return n |
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
class (Show a, Read a) => PlainTextDB a where | |
get :: IO a | |
get = fmap read $ readFile "db.txt" | |
set :: a -> IO () | |
set x = return (show x) >>= writeFile "db.txt" | |
instance PlainTextDB Int | |
main = do | |
set (4 :: Int) |
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
#include <tr1/type_traits> | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
// (* -> *) -> Constraint | |
template<template <typename> class T> | |
class Functor { | |
public: | |
template <typename A, typename 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 DataKinds, KindSignatures, GADTs, RankNTypes #-} | |
data K = X | Y | |
data Box (a :: K) where | |
Box :: Box a | |
class Foo (a :: K) where | |
name :: Box a -> String |