Skip to content

Instantly share code, notes, and snippets.

View chessai's full-sized avatar

chessai chessai

View GitHub Profile
# Install not only the Hoogle library and executable, but also a local Hoogle
# database which provides "Source" links to all specified 'packages' -- or the
# current Haskell Platform if no custom package set is provided.
#
# It is intended to be used in config.nix similarly to:
#
# { packageOverrides = pkgs: rec {
#
# haskellPackages =
# let callPackage = pkgs.lib.callPackageWith haskellPackages;
combine :: Monoid e
=> (a -> Either e r1)
-> (b -> Either e r2)
-> (a,b)
-> Either (Either e1 (e1,e2)) (r1,r2)
combine fa fb (a,b) =
let faa = fa a
fbb = fb b
in case faa of
Left e1 -> Left (Left e1)
{-# OPTIONS_GHC -fforce-recomp -ddump-simpl -fno-worker-wrapper -dsuppress-all #-}
module Main (main) where
import System.Environment (getArgs)
main :: IO ()
main = do
[x,y] <- map read <$> getArgs
let f1 = f x A B
module Example (main) where
import Data.IORef
import Data.Primitive
import Data.Primitive.PrimArray
import GHC.Prim (RealWorld)
main :: IO ()
main = do
let len = 30
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Main where
import Data.Aeson
import qualified Data.ByteString.Lazy.Char8 as LBSC8
import Data.List (sort)
type Pairs = [(Double,Double)]
type Measure = [Double] -> Double
midpoints :: Pairs -> [Double]
midpoints = map (\(x, y) -> (x + y) / 2)
mean :: Measure
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UnboxedTuples #-}
import GHC.IO.Handle.Internals
import GHC.IO.Exception
import GHC.Ptr
import GHC.IO
@chessai
chessai / aesont.hs
Created February 26, 2019 18:36
derive json automatically for the way i usually write my record product types
data Settings = Settings
{ settingsFoo :: Int
, settingsBar :: String
, settingsBaz :: [Int]
}
deriving (stock) Generic
instance FromJSON Settings where
parseJSON = parseJSONFielded
@chessai
chessai / dict_py2hs.txt
Created March 18, 2019 16:46
python dict to haskell [(k,v)]
\(\d\+\): \(\d\+\)/(\1,\2)
Building build.rs (librocksdb-sys)
Running rustc --crate-name build_script_build build.rs --crate-type bin -C opt-level=3 -C codegen-units=1 --cfg feature="zstd" --cfg feature="zlib" --cfg feature="static" --cfg feature="snappy" --cfg feature="lz4" --cfg feature="default" --cfg feature="bzip2" --out-dir target/build/librocksdb-sys --emit=dep-info,link -L dependency=target/buildDeps --extern bindgen=/nix/store/ksq6msrj8lxn771j7q4wmnjfx58rcfy9-rust_bindgen-0.47.3/lib/libbindgen-257b470b9c.rlib --extern cc=/nix/store/2bihshk564grlwk8jllqb6niwyj58j6a-rust_cc-1.0.32/lib/libcc-d214a1c57c.rlib --extern glob=/nix/store/ffzh87sjai1hqj046g69gr99pdbsvbqy-rust_glob-0.2.11/lib/libglob-67202cca89.rlib --cap-lints allow -L native=/nix/store/vrzv48gkazkwkbn1v9x0fcxsyja3bdiw-rust_backtrace-sys-0.1.28/lib/backtrace-sys.out -L native=/nix/store/xv6f9l6sg5mfsam2ak78qysda66nf368-rust_libloading-0.5.0/lib/libloading.out -l dl -l static=backtrace -l static=global_static --color always
thread 'main' panicked at 'Unable to find libcl