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 PolyKinds, GADTs, StandaloneDeriving, UndecidableInstances, FunctionalDependencies, FlexibleContexts, MultiParamTypeClasses, ConstraintKinds, DataKinds, TypeOperators, FlexibleInstances, Rank2Types, ScopedTypeVariables #-} | |
import Prelude hiding (id, (.)) | |
import Data.Monoid | |
import Data.Extensible -- extensible | |
import Data.Extensible.Dictionary | |
import Data.Extensible.Internal | |
import Data.Extensible.Internal.Rig | |
import GHC.Prim |
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
-- (a, b, c ...) represents a sum of effects a, b, c... | |
-- They do not occur simultaneously | |
-- f ~> g is the type of objects that handles f, works on g | |
-- the player handles key events and external events to produce motion, sound effects, outgoing events, and death | |
player :: (Control, Event) ~> (Motion, SoundEffect, Event, Death) | |
player = \(sp, ev) ~> hideContext $ do | |
-- | Create new context | |
hp <- newContext |
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 MultiParamTypeClasses | |
, FlexibleInstances | |
, TypeFamilies | |
, OverlappingInstances | |
, IncoherentInstances #-} | |
class WTF a b e where | |
($$) :: [a] -> e -> [b] | |
infixl 5 $$ | |
instance (a ~ c, b ~ d) => WTF a b (c -> d) where |
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 Control.Object | |
import Control.Object.Mortal | |
data Claim a' a b' b where | |
UNeed :: Claim a' a b' b a' | |
UGive :: a -> Claim a' a b' b () | |
DNeed :: Claim a' a b' b b | |
DGive :: b' -> Claim a' a b' b () | |
type Proxy a' a b' b = Mortal (Claim a' a b' 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
data Digit a = One !a | Two !a !a | |
data Tree a = Nil | Tree (Digit a) (Tree a) (Tree a) | |
cons :: a -> Tree a -> Tree a -- O(1) | |
cons a Nil = Tree (One a) Nil Nil | |
cons a (Tree (One b) xs ys) = Tree (Two a b) xs ys | |
cons a (Tree (Two b c) xs ys) = Tree (One a) (cons b xs) (cons c ys) |
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 Ya p where | |
ya :: (forall x. f x -> g x) -> p f g | |
(>>>>) :: p f g -> p g h -> p f h | |
(>>>^) :: p f g -> (forall x. g x -> h x) -> p f h | |
a >>>^ b = a >>>> ya b | |
(^>>>) :: (forall x. f x -> g x) -> p g h -> p f h | |
a ^>>> b = ya a >>>> 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 TemplateHaskell, DataKinds, LambdaCase, KindSignatures, MultiParamTypeClasses, FunctionalDependencies, TypeFamilies, Rank2Types #-} | |
module Idiom.Lens where | |
import Language.Haskell.TH | |
import Language.Haskell.TH.Lens | |
import Data.Proxy | |
import Control.Lens | |
import GHC.TypeLits | |
class Has (s :: Symbol) a where |
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
[ x + y | |
| x <- [1..10] | |
, y <- [1..3]] | |
do | |
x <- [1..10] | |
y <- [1..3] | |
return (x + 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
# "路線コード": { | |
# "駅コード": (X, Y, Z, "駅名"), ... | |
# }, ... | |
stationInfoTable = { | |
# harutrak A | |
"HA": { | |
"HH": (-285, 59, 346, "役場前"), | |
"NV": (-369, 70, 115, "中村"), # 298 blocks | |
"MM": (-370, 69, -56, "メガネケエスタワー前"), # 161 blocks |
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 Rank2Types #-} | |
import FreeGame | |
import FreeGame.Class | |
import Debug.Trace | |
import FreeGame.Component | |
import FreeGame.Component.Deck | |
meter deck = oneshot $ \(PullGraphic _ cont) -> do | |
let s x = (10 + max (log x / log 10) (-10)) / 10 | |
V2 a b <- fmap (fmap s) $ deck .- RMS 1024 |