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
% nix develop github:alpmestan/ghc.nix#js-cross | |
ghc.nix ~ cd ghc-js | |
ghc.nix ~ ./boot | |
ghc.nix ~ sdk_path="$(xcrun --sdk macosx --show-sdk-path)" | |
ghc.nix ~ ghc_configure --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi | |
ghc.nix ~ hadrian/build -j4 --flavour=Quick --bignum=native --docs=none |
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
-- short-circuiting folds | |
import Prelude hiding (foldl, foldr) | |
foldl :: (b -> a -> b) -> b -> [a] -> b | |
foldl f a [] = a | |
foldl f a (x:xs) = foldl f (f a x) xs | |
foldr :: (a -> b -> b) -> b -> [a] -> b | |
foldr f z [] = z |
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
data A = A1 | A2 deriving Show | |
data B = B1 | B2 | B3 deriving Show | |
type PairAB x = (A -> B -> x) -> x | |
pairAB :: A -> B -> PairAB x | |
pairAB a b g = g a b | |
fstAB :: PairAB A -> A -- ((A -> B -> A) -> A) -> A | |
fstAB p = p (\x y -> 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
{-# LANGUAGE DeriveAnyClass #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module Database ( | |
Database, | |
Key, Value, | |
createDB, | |
get, set, | |
rcdata |
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 DeriveAnyClass #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module Database ( | |
Database, | |
Key, Value, | |
createDB, | |
get, set, | |
rcdata, |
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 TemplateHaskell, DeriveDataTypeable, DeriveGeneric #-} | |
{-# LANGUAGE RecordWildCards #-} | |
{-# LANGUAGE LambdaCase #-} | |
import Control.Distributed.Process | |
hiding (Message, mask, finally, handleMessage, proxy) | |
import Control.Distributed.Process.Backend.SimpleLocalnet (Backend, findPeers, initializeBackend, newLocalNode) | |
import Control.Distributed.Process.Closure | |
import Control.Distributed.Process.Node (initRemoteTable, runProcess) | |
import Control.Concurrent.Async | |
import Control.Monad.IO.Class |
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 Data.List (unfoldr) | |
-- Recursive definition of binomial coefficient | |
-- Can take exponential time in n + k | |
-- Try binom_r 25 10 -- already takes several seconds | |
binom_r :: Int -> Int -> Integer | |
binom_r n 0 = 1 | |
binom_r n k | n == k = 1 | |
| otherwise = binom_r (n-1) (k-1) + binom_r (n-1) k |
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
#!/usr/bin/env stack | |
-- stack script --resolver lts-14.9 --package=HExcel | |
import HExcel | |
main = do | |
wb <- workbookNew "buggy-dates.xls" | |
let props = mkDocProperties | |
{ docPropertiesTitle = "Buggy Dates" | |
, docPropertiesCompany = "" |
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 FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Lib | |
( HasDummy | |
, Injectable | |
, Product | |
, Union | |
, pair |
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
resolver: lts-6.35 # need to set this to old resolver | |
flags: | |
parconc-examples: | |
distributed: true | |
accelerate: true | |
devil: true # need to set this to build repa-devil | |
extra-package-dbs: [] | |
packages: | |
- '.' | |
extra-deps: |
NewerOlder