Skip to content

Instantly share code, notes, and snippets.

View funrep's full-sized avatar

Karl-Oskar Rikås funrep

View GitHub Profile
%{
#define YYSTYPE double /* data type of yacc stack */
%}
%token NUMBER
%left '+' '-' /* left associative, same precedence */
%left '*' '/' /* left assoc., higher precedence */
%left UNARYMINUS
%%
list: /* nothing */
| list '\n'
{-# LANGUAGE OverloadedStrings #-}
module Tob.Parser where
-- (maybe ':') (maybe adress) (command) (params) (maybe ':') (maybe stuff)
import Prelude hiding (takeWhile)
import Control.Applicative ((<|>))
import Data.Text (Text)
import Data.Char (isUpper)
import Data.Attoparsec.Text
@funrep
funrep / weird.md
Last active January 1, 2016 23:38
pipe inp s = inp >>= \x -> sh $ T.concat ["echo ", "\"", x, "\"", " | ", s]
DotHellRC.hs:37:33:
    Couldn't match expected type `Data.Text.Lazy.Internal.Text'
                with actual type `T.Text'
    In the return type of a call of `T.concat'
 In the second argument of `($)', namely
{-# LANGUAGE RecordWildCards, OverloadedStrings #-}
import Prelude hiding (Either(..))
import Data.IntMap (IntMap)
import qualified Data.IntMap as IM
import System.IO (Handle)
import Network (withSocketsDo, listenOn, accept, PortID(..))
import qualified Data.ByteString.Lazy as B
import Data.Aeson
import Control.Applicative
{-# LANGUAGE RecordWildCards #-}
import Prelude hiding (Either(..))
import Data.IntMap (IntMap)
import qualified Data.IntMap as IM
import System.IO (Handle)
import Network (withSocketsDo, listenOn, accept, PortID(..))
import qualified Data.ByteString as B
import Data.Aeson
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:bar@hackage.haskell.org/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