Skip to content

Instantly share code, notes, and snippets.

View isovector's full-sized avatar

Sandy Maguire isovector

View GitHub Profile
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
runStoryApp :: Comonad w => StoryApp a -> CoStoryAppT w b -> (a, b)
runStoryApp = pairEffect (,)
runStory :: Comonad w => Story a -> CoStoryT w b -> (a, b)
runStory = pairEffect (,)
mkCoStoryApp :: Comonad w
=> w b
-> (w b -> Character -> ChangeType -> w b)
-> (forall x y . (forall a. Story a -> b)
type family Apply g a b :: * where
Apply (->) a b = a -> b
Apply Snd a b = b
data StoryF g a = Change Character ChangeType (Apply g ChangeResult a)
| forall x x'. Interrupt (Free (StoryF g) x')
(Free (StoryF g) x)
(Apply g x a)
| Macguffin (Apply g Desirable a)
module RPG.Data.StoryImpl
( runStory
, dopestory
, mkCoStory
) where
import Control.Comonad
import Control.Comonad.Trans.Cofree
import Control.Monad (void)
import Control.Monad.IO.Class
module Components.KeySelector where
import Graphics.Input exposing (button)
keySelector : (Note -> a) -> Signal.Address a -> Element
keySelector f address = flow right
<< flip List.map noteEnum.elems
<| \note ->
button (Signal.message address <| f note)
<| toString note
@isovector
isovector / Test.hs
Last active November 29, 2015 03:13
module Test where
import Control.Concurrent.MVar
import Control.Monad.IO.Class
import Control.Monad (join)
-- Memoize an IO result
memoIO :: MonadIO m => m a -> m (m a)
memoIO action = do
ref <- liftIO $ newMVar Nothing
@isovector
isovector / xmonad.hs
Created July 16, 2015 22:35
xmonad.hs
import Prelude hiding (mod)
import Control.Monad (when, liftM2)
import System.Environment (getArgs)
import System.IO
import XMonad
import XMonad.Actions.DynamicWorkspaces
import XMonad.Actions.WindowGo
import XMonad.Layout.Fullscreen
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
type Inventory = (Game, Int)
type UserRank = (User, (Game, Int))
unwrapPair :: Monad m => (a, m b) -> m (a, b)
type App = ReaderT (AcidState Database) (ServerPartT IO)
processForm :: App Response
processForm =
do method POST
db <- ask
(games, _) <- query db (GetState) ----- this part explodes
prefs <- sequence $ map (runText . fst) prefMap
ok $ template "form" $ H.p "success!"
package juicy.source.ast
trait Expression extends Visitable
trait Statement extends Visitable
trait BinOp extends Expression {
val lhs: Expression
val rhs: Expression
protected def rewriter[T <: BinOp]