Skip to content

Instantly share code, notes, and snippets.

Stephen Diehl sdiehl

Block or report user

Report or block sdiehl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View DataTypeName.hs
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
module Test where
import GHC.Generics
import Data.Proxy
typeName :: forall a. (Generic a, GTypeName (Rep a)) => Proxy a -> String
typeName Proxy = gtypename (from (undefined :: a))
View dict.sh
rivendell% stack ghci not sandboxed
Configuring GHCi with the following packages:
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/sdiehl/.ghci
Loaded GHCi configuration from /tmp/ghci18272/ghci-script
λ> class Foo a where { foo :: a -> Int }
λ> instance Foo () where { foo _ = 3 }
λ> bar = foo ()
λ> bar
3
View alphasheets.md

What we're building

Collaborative, programmable spreadsheets. Think Google Sheets, but like this.

You can check more examples out at alphasheets.com.

What the job entails

View list_combinator.hs
list :: [b] -> (a -> b) -> [a] -> [b]
list def f xs = case xs of
[] -> def
_ -> fmap f xs
example :: [String]
example = list ["a"] show [1,2,3]
View Test.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ConstraintKinds #-}
module Data.HdrHistogram.Config.Test where
import Data.Proxy
import GHC.TypeLits (Nat, type (<=))
View gist:e0b0b55ffc1c28ab1a0b
$ conda list | grep llvm
llvm 3.3 0 <unknown>
llvmlite 0.8.0 py27_0 defaults
llvmpy 0.12.7 py27_0 <unknown>
View hello.ll
; 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 }
View Eval.hs
module Eval (
eval
) where
import Syntax
import Data.Functor ((<$>))
isNum :: Expr -> Bool
isNum Zero = True
isNum (Succ x) = isNum x
View MurmurHash2.c
//-----------------------------------------------------------------------------
// 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"
View namedtuple.py
_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})'
You can’t perform that action at this time.