Skip to content

Instantly share code, notes, and snippets.

View funrep's full-sized avatar

Karl-Oskar Rikås funrep

View GitHub Profile
import Data.IntMap (IntMap)
import qualified Data.IntMap as IM
import qualified Data.HashMap.Strict as HM
import Data.Aeson
transformIM :: ToJSON a => IntMap a -> Object
transformIM = HM.map toJSON . HM.fromList . convertKeys . IM.toList
where convertKeys = map (\(k, v) -> (T.pack $ show k, v))
@funrep
funrep / game.hs
Last active December 30, 2015 00:49
{-# LANGUAGE Rank2Types #-}
import Data.Word (Word8)
import Data.Bits (shiftL, (.|.))
import qualified Graphics.UI.SDL as SDL
import qualified Graphics.UI.SDL.Primitives as Prims
import Reactive.Banana
import Reactive.Banana.Frameworks
{------------------------------------------------------------------------------
$ curl -X PUT -H 'Content-Type: application/x-tar' -d @dist/doc.tar http://foo:[email protected]/package/verbalexpressions-1.0.0.0/docs
Warning: Couldn't read data from file "dist/doc.tar", this makes an empty
Warning: POST.
Invalid documentation tarball: truncated tar archive
{-# LANGUAGE Rank2Types #-}
import qualified Graphics.UI.SDL as SDL
import Reactive.Banana
import Reactive.Banana.Frameworks
{------------------------------------------------------------------------------
Main
---------------------------------------------------------------------------}
@funrep
funrep / frp.hs
Created November 27, 2013 14:01
right :: Event t Bool
left :: Event t Bool
ship = accumB 100 move
move n = whenMove left (fmap ($ n) add)
`union` whenMove right (fmap ($ n) sub)
add = once (+ 1) <@ tick
sub = once (flip (-) 1) <@ tick
@funrep
funrep / game.hs
Last active December 29, 2015 10:59
{-# LANGUAGE Rank2Types #-}
import qualified Graphics.UI.SDL as SDL
import Reactive.Banana
import Reactive.Banana.Frameworks
{------------------------------------------------------------------------------
Main
---------------------------------------------------------------------------}
-- I'm currently trying to translate this code https://github.com/bernstein/breakout/blob/master/src/ReactiveUtils.hs
-- to use linear package instead of vector-space, and I'm not sure if I've understood diffE completely.
import Linear.Vector
import Reactive.Banana
type Time = Double
integral :: (Additive f, Num a) => Event t Time -> Behavior t (f a)
-> Behavior t (f a)
integral :: Additive a => Event t Time -> Behavior t a -> Behavior t a
integral t b = sumB $ (\v dt -> dt *^ v) <$> b <@> diffE t
// Nexuiz version (formatted for humans)
set g_nexuizversion "2.1"
// Nexuiz version (formatted for machines)
// used to determine if a client version is compatible
// this doesn't have to be bumped with every release
// bump when clients become incompatible or any other perfectly good reason
// (e.g. game data incompatibility, engine version incompatibility, etc
// note: this automatically filters the server browser, clients of the new
// version won't see old servers, and clients of the old version won't see new
module Main where
import Hell
import DotHellRC
main = startHell def { configImports = "import DotHellRC" : configImports def }