Skip to content

Instantly share code, notes, and snippets.

View guibou's full-sized avatar
🛩️
Diving in a sky full of escaped skolems

Guibou guibou

🛩️
Diving in a sky full of escaped skolems
  • Saint-Paul - Reunion - France
  • 13:43 (UTC +04:00)
View GitHub Profile
with import <nixpkgs> {};
let
makeDaemons = haskellPackages: networkName: haskellPackages.callCabal2nix "daemons"
(builtins.filterSource (type: name: name != "default.nix") ./.)
{
network = builtins.getAttr networkName haskellPackages;
};
haskellCompilers = with haskell.packages; [ ghc882 ghc865 ghc844 ];
# "network" is:
{-# LANGUAGE BangPatterns #-}
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector as V
import Control.Monad.ST
import Unsafe.Coerce
data Stream = Output Int Stream | Input (Int -> Stream) | End [Int]
foo :: [Int] -> Stream
@guibou
guibou / TortueLama12.hs
Created September 12, 2019 22:26
Haskell build with unresolved type family
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeApplications #-}
data Foo k = Foo
type family Bar a b where
Bar Int Int = Int
# Empty
@guibou
guibou / ReifyGADTWildCard.hs
Created May 27, 2019 12:52
I'd like to pattern match on some GADT constructor and get the associated type in scope and I'd like it to work with wildcard in cases were all the cases are known, but apparently it does not type check.
{-# OPTIONS -Wall #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE GADTs #-}
-- Note that all the @@t@@ in this GADT are explicit
-- So at compile time, there is no ambiguity on this list
data Foo t where
A :: Foo [Int]
[1 of 1] Compiling Main ( Foo.hs, Foo.o )
GHC iserv starting (in: 13; out: 12)
iserv: MallocStrings []
iserv: return: []
iserv: InitLinker
iserv: return: ()
iserv: AddLibrarySearchPath "/nix/store/bvq5y8izgrfbbvw7c5rryyqj3c8aja6y-ghc-8.6.3/lib/ghc-8.6.3/ghc-prim-0.5.3"
iserv: return: RemotePtr 0
iserv: AddLibrarySearchPath "/nix/store/gwqjqi08i0imii0xyzq8lgql68wiqayn-sane-config/lib/sane"
iserv: return: RemotePtr 0
@guibou
guibou / Floyd.hs
Last active November 29, 2018 19:45
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.Vector.Unboxed.Mutable as Vector
import System.Random
import Data.Foldable (for_)
main :: IO ()
main = do
let n = 500
@guibou
guibou / hardfloat.nix
Last active November 22, 2018 14:29
`foo` builds with `gcc-arm-embedded` but `bar` does not, with `pkgsCross.arm-embedded`.
let
nixos1809 = import (fetchTarball channel:nixos-18.09) {};
file = nixos1809.writeTextFile {
name = "file.c";
text = ''
#include <math.h>
int _exit(int i){};
int main()
{
@guibou
guibou / DerivingVia.md
Created October 26, 2018 08:15
Questions about `DerivingVia`

I have a MultiParamTypeClass issue with DerivingVia.

I have this type and class:

{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE DerivingVia #-}
@guibou
guibou / Huffman.hs
Created September 5, 2018 21:28
Fast Huffman trees
module Huffman where
import qualified Data.Map.Strict as Map -- from containers
import Data.Map (Map)
import qualified Data.PQueue.Prio.Min as PQueue -- from pqueues
-- | Compute a weight map of symbols
-- The weights are not normalized, I don't really care
-- Complexity: O(n log n), with n ~ length input