This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> ("Hello", ("there", ["are","several"]),Left "Strings", "in", "here") | |
& partsOf template %~ (reverse :: [String] -> [String]) | |
("here",("in",["Strings","several"]),Left "are","there","Hello") | |
>>> ("Hello", ("there", ["are","several"]),Left "Strings", "in", "here") | |
& partsOf template %~ (reverse :: String -> String) | |
("erehn",("isgni",["rtS","lareves"]),Left "eraereh","to","lleH") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ExistentialQuantification #-} | |
module MyLib where | |
import Data.Foldable (toList) | |
import Control.Applicative |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
// #include <benchmark/benchmark.h> | |
const size_t popcount(uint16_t x) { | |
return __builtin_popcount(x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Primes where | |
primes :: [Integer] | |
primes = 2 : 3 : filter isPrime [5,7..] | |
isPrime :: Integer -> Bool | |
isPrime n = all (\x -> n `mod` x /= 0) $ takeWhile (\x -> x*x <= n) primes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compile :: ByteString -> [PCREOption] -> Either String Regex | |
compile str flags = unsafePerformIO $ | |
useAsCString str $ \pattern -> do | |
alloca $ \errptr -> do | |
alloca $ \erroffset -> do | |
pcre_ptr <- c_pcre_compile pattern (combineOptions flags) errptr erroffset nullPtr | |
if pcre_ptr == nullPtr | |
then do | |
err <- peekCString =<< peek errptr | |
return (Left err) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-- 1 | |
1 1 | |
1 2 1 | |
1 3 3 1 | |
1 4 6 4 1 --} | |
-- printRow :: (Integral a, Show a) => a -> [a] -> IO () | |
printRow :: Int -> [Int] -> IO () | |
printRow pad nums = do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE DataKinds #-} | |
import Generics.SOP | |
import Data.List (intercalate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Applicative | |
import Control.Monad | |
import Data.Map.Strict (Map, (!)) | |
import qualified Data.Map.Strict as Map | |
import Data.Monoid | |
import Data.String | |
import Data.Text | |
import Language.Haskell.TH | |
import System.Exit | |
import System.IO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Scales colours found in a given file by a given factor, manages ~150MB/s | |
{-# LANGUAGE OverloadedStrings #-} | |
import Data.Attoparsec.ByteString (Parser, satisfy) | |
import Data.Attoparsec.ByteString.Lazy as A | |
import Data.ByteString.Lazy as BSL hiding (concatMap, map) | |
import Data.Monoid ((<>)) | |
import Data.Word (Word8) | |
import Prelude hiding (readFile, writeFile) | |
import System.Environment (getArgs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allPowerStationsQuery :: Query () (Vector PowerStation2) | |
allPowerStationsQuery = | |
statement | |
"SELECT participant, station_name, region, dispatch_type, \ | |
\ category, classification, fuel_source_primary,\ | |
\ fuel_source_descriptor, tech_type_primary,\ | |
\ physical_unit_no, unit_size_m_w, aggregation,\ | |
\ duid, reg_cap_m_w, max_cap_m_w, max_r_o_c_per_min\ | |
\FROM duid_location;" | |
enc dec True |
NewerOlder