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 --install-ghc runghc --package sbv | |
import Data.Foldable | |
import Data.SBV | |
-- Encoding the Subset sum problem | |
-- https://en.wikipedia.org/wiki/Subset_sum_problem | |
subsetSum :: [SInt64] -> SInt64 -> Int -> IO SatResult | |
subsetSum set target subsetLength = sat $ 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
#!/usr/bin/env stack | |
-- stack --install-ghc runghc --package sbv | |
import Data.SBV | |
main = | |
print =<< | |
(sat $ | |
\lo m2 m1 hi -> | |
((lo :: SInt8) + m2 + m1 + hi .== 31) |
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
#!/bin/bash -x | |
# % ghc --version | |
# The Glorious Glasgow Haskell Compilation System, version 7.6.3 | |
cabal -j --max-backjumps -1 install hlearn-distributions-1.0.0.2 vector-heterogenous-0.1.2 ConstraintKinds-0.0.1 |
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
FROM ubuntu | |
RUN sudo apt-get update && sudo apt-get -y install aptitude software-properties-common git | |
RUN sudo aptitude -y install zlib1g-dev libcurl3-dev libpq-dev | |
RUN sudo add-apt-repository -y ppa:hvr/ghc && sudo aptitude update && sudo aptitude -y install cabal-install-1.20 ghc-7.8.3 happy-1.19.4 alex-3.1.3 && export PATH=/opt/alex/3.1.3/bin:/opt/happy/1.19.4/bin:$PATH && export PATH=/opt/ghc/7.8.3/bin:$PATH && cabal-1.20 update && cabal-1.20 -j -O2 install cabal-install | |
RUN export PATH=/opt/alex/3.1.3/bin:/opt/happy/1.19.4/bin:$PATH && export PATH=/opt/ghc/7.8.3/bin:$PATH && export PATH=$HOME/.cabal/bin:$PATH && git clone https://github.com/haskell/cabal.git && cd cabal && cd Cabal && cabal -j -O2 install && cd .. && cd cabal-install && cabal -j install -O2 && cd .. | |
RUN export PATH=/opt/alex/3.1.3/bin:/opt/happy/1.19.4/bin:$PATH && export PATH=/opt/ghc/7.8.3/bin:$PATH && export PATH=$HOME/.cabal/bin:$PATH && git clone https://github.com/chrisdone/lpaste.git && cd lpaste && cabal sandbox init && cabal - |
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 FoundIt (FoundIt.elem) where | |
import Data.Semigroup | |
import Data.List.NonEmpty (NonEmpty(..)) | |
data FoundIt a = FoundIt (a -> Bool) a | |
instance (Eq a) => Eq (FoundIt a) where | |
f1 == f2 = | |
case (f1, f2) of |
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 bash | |
cabal configure && cabal build && cabal haddock --hyperlink-source \ | |
--html-location='/package/$pkg-$version/docs' \ | |
--contents-location='/package/$pkg' | |
S=$? | |
if [ "${S}" -eq "0" ]; then | |
cd "dist/doc/html" | |
DDIR="${1}-${2}-docs" | |
cp -r "${1}" "${DDIR}" && tar -c -v -z --format=ustar -f "${DDIR}.tar.gz" "${DDIR}" | |
CS=$? |
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 ParseDate where | |
import Data.Monoid | |
import qualified Data.Foldable as F | |
import Control.Newtype | |
import Data.Time.Calendar | |
import Data.Time.Clock | |
import Data.Time.LocalTime | |
import Data.Time.Format |
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
namedtuple is implemented an eval'd string in python, this implementation would likely copy that | |
```python | |
import geohash | |
Foo = initializednamedtuple('Foo', [ | |
'lat', | |
'long', | |
('geohash', lambda self, geohash: geohash if geohash else geohash.geohash(self.lat, self.long)) | |
]) |
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 #-} | |
import Data.DeriveTH | |
import Data.Derive.Show | |
import Language.Haskell.TH.Module.Magic | |
newtype Foo = Foo (Int, String) | |
data Bar a = Bar Int | Baz a (Bar a) | |
foo :: Foo -> Int -> String | |
foo (Foo (n, s)) x = if n == x then s else "" |
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 ATComposeProductSum where | |
import Control.Applicative | |
import Data.Traversable | |
import Data.Functor.Compose | |
import Data.Functor.Product | |
import Data.Functor.Sum | |
import Data.Functor.Identity |
NewerOlder