Skip to content

Instantly share code, notes, and snippets.

View isovector's full-sized avatar

Sandy Maguire isovector

View GitHub Profile
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
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)
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)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE InstanceSigs #-}
@isovector
isovector / cvim
Created September 23, 2016 18:09
map d closeTab
map <Enter> openCommandBar
map <C-A> incrementURLPath
map <C-X> decrementURLPath
map u lastClosedTab
unmap x
let barposition = "bottom"
let qmark g = ["http://github.com/isovector"]
let qmark m = ["http://gmail.com"]
let qmark b = ["http://goodreads.com"]
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
@isovector
isovector / pascal.hs
Created January 8, 2017 00:14
pascal dot haskell
import Data.Semigroup
import Control.Comonad
import Control.Comonad.Store
pascalLine :: Store (Int, Int) Int -> Int
pascalLine w | x <= 0 = 1
| y <= 0 = 1
| otherwise = peek (x-1, y) w + peek (x, y-1) w
where
(x, y) = pos w
@isovector
isovector / leprc
Last active February 16, 2017 00:31
leprechaun
doom
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Detergo where
import Control.Monad (when)
import Data.List (intercalate)
import Data.Maybe (listToMaybe)
data Level = Low | Medium | High