Skip to content

Instantly share code, notes, and snippets.

View sdiehl's full-sized avatar
💭
I may be slow to respond.

Stephen Diehl sdiehl

💭
I may be slow to respond.
View GitHub Profile
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ConstraintKinds #-}
module Data.HdrHistogram.Config.Test where
import Data.Proxy
import GHC.TypeLits (Nat, type (<=))
$ conda list | grep llvm
llvm 3.3 0 <unknown>
llvmlite 0.8.0 py27_0 defaults
llvmpy 0.12.7 py27_0 <unknown>
@sdiehl
sdiehl / hello.ll
Last active December 13, 2015 20:01
; ModuleID = '-'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%Si = type <{ i64 }>
%Vs5Int32 = type <{ i32 }>
%Sp = type <{ i8* }>
%swift.type = type { i64 }
%swift.type_pattern = type opaque
%swift.protocol = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i32, i32 }
module Eval (
eval
) where
import Syntax
import Data.Functor ((<$>))
isNum :: Expr -> Bool
isNum Zero = True
isNum (Succ x) = isNum x
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
// Note - The x86 and x64 versions do _not_ produce the same results, as the
// algorithms are optimized for their respective platforms. You can still
// compile and run any of them on any platform, but your performance with the
// non-native version will be less than optimal.
#include "MurmurHash3.h"
_class_template = '''\
class {typename}(tuple):
'{typename}({arg_list})'
__slots__ = ()
_fields = {field_names!r}
def __new__(_cls, {arg_list}):
'Create new instance of {typename}({arg_list})'
@sdiehl
sdiehl / gist:507a63fcff404e79fa5b
Created February 8, 2015 03:02
vim dictionary
Diehl
Asymptotics
frontend
AST
desugar
primops
unboxed
desugaring
Lexer
REPL
@sdiehl
sdiehl / Eval.hs
Last active August 29, 2015 14:13
Mini interpreter with State
module Eval (eval) where
import Syntax
import Control.Monad.State
import qualified Data.Map as Map
data Value
= VInt Int
| VUnit
@sdiehl
sdiehl / state.hs
Created January 13, 2015 18:44
State monad implementation + example
import Control.Monad
-------------------------------------------------------------------------------
-- State Monad Implementation
-------------------------------------------------------------------------------
newtype State s a = State { runState :: s -> (a,s) }
instance Monad (State s) where
return a = State $ \s -> (a, s)
@sdiehl
sdiehl / Example.hs
Last active April 14, 2016 16:51
Type Level String Concatenation
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
import TypeLevelString