Skip to content

Instantly share code, notes, and snippets.

View chessai's full-sized avatar

chessai chessai

View GitHub Profile
{-# 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
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 LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Main where
import Data.Aeson
import qualified Data.ByteString.Lazy.Char8 as LBSC8
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
{-# 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
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)
# 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;
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.choogle;
hoogleEnv = pkgs.buildEnv {
name = "hoogle";
{-# language BangPatterns #-}
{-# language ScopedTypeVariables #-}
{-# language UnboxedTuples #-}
module Array (mapMaybe) where
import Control.Monad.ST
import Data.Primitive.Array
data Alls = AllNothing | NotAllNothing
reverseBits :: Word8 -> Word8
reverseBits b' =
let b = fromIntegral b' :: Word32
!x = ((((b * 0x0802 .&. 0x22110) .|. ((b * 0x8020) .&. 0x88440)) * 0x10101) `unsafeShiftR` 16
in fromIntegral x