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 Prelude | |
import Parsing | |
import Either | |
foreign import data JSON :: * | |
foreign import toJSON "function toJSON (obj) { return obj; }" :: forall a. a -> JSON | |
foreign import showJSON "function showJSON (obj) { return JSON.stringify(obj); }" :: JSON -> 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
data Zero = Zero | |
data Succ a = Succ a | |
pred = \s -> case s of Succ a -> a | |
meters = \n -> | |
{ multiply: \v -> v { value = n * v.value, meters = Succ (v.meters) } | |
, divide: \v -> v { value = n / v.value, meters = pred (v.meters) } | |
} |
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
data Zero = Zero | |
data Succ a = Succ a | |
pred = \s -> case s of Succ a -> a | |
meters = \n v -> v { value = n * v.value, meters = Succ (v.meters) } | |
seconds = \n v -> v { value = n * v.value, seconds = Succ (v.seconds) } |
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 PolymorphicComponents, GeneralizedNewtypeDeriving, DeriveDataTypeable #-} | |
import Data.Data | |
import Data.Maybe | |
import Data.Generics | |
import Data.Monoid | |
import Control.Applicative | |
import Control.Monad.State | |
import Control.Monad.Logic | |
import Control.Monad.Logic.Class |
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 GeneralizedNewtypeDeriving #-} | |
import Control.Applicative (Applicative(..), Alternative(..)) | |
import Data.Function (fix) | |
import qualified Control.Category as C | |
import Control.Category ((>>>)) | |
import qualified Control.Arrow as A | |
import Control.Arrow ((***)) | |
newtype Pattern a b = Pattern { runPattern :: A.Kleisli Maybe a b } deriving (C.Category, A.Arrow) |
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, MultiParamTypeClasses, PolyKinds, TypeOperators, FlexibleInstances, TypeFamilies, UndecidableInstances #-} | |
import GHC.TypeLits | |
module Knockout where | |
data PrimType = String | Number | |
data Model | |
= ObsPrim { primType :: PrimType } |
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
pauseTime = 0.35 | |
timePerThrow = 300 | |
handMovement = 0.2 | |
pattern = [5] | |
rotatePattern : Int -> [a] -> [a] | |
rotatePattern n xs = |
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 FlexibleContexts #-} | |
module Markup where | |
import Text.Parsec | |
import qualified Text.Parsec.Token as P | |
import qualified Text.Parsec.Language as L | |
import qualified Text.Parsec.Expr as E | |
import Data.Char | |
import Data.List (groupBy, nub, (\\)) |
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 Text.Parsec | |
data Tree a = Tip a | Branch (Tree (a, a)) deriving (Show) | |
tree :: Parsec String u (Tree Int) | |
tree = tree' $ do | |
ds <- many digit | |
return $ read ds | |
where | |
tree' :: Parsec String u a -> Parsec String u (Tree 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 GADTs #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE UndecidableInstances #-} |