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
type family Repeat (n :: Nat) (a :: *) :: [*] where | |
Repeat 'Zero a = '[] | |
Repeat ('Succ n) a = a ': Repeat n a | |
fromHomSum :: SNat n -> NS f (Repeat n a) -> f a | |
fromHomSum SZero ns = case ns of {} | |
fromHomSum (SSucc _) (Z a) = a | |
fromHomSum (SSucc n) (S as) = fromHomSum n as | |
toHomProd :: [f a] -> (forall n. SListI (Repeat n a) => SNat n -> NP f (Repeat n a) -> b) -> b |
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 Blog where | |
import Prelude hiding ((.), id) | |
import Control.Category | |
import Data.Bifunctor | |
{------------------------------------------------------------------------------- | |
Fixed points | |
-------------------------------------------------------------------------------} |
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 GADTs #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# OPTIONS_GHC -Wall -fno-warn-incomplete-patterns #-} | |
module HdWalletNotes where | |
{------------------------------------------------------------------------------- | |
This module is a simple Haskell model of BIP-32, with a focus on why and | |
how hardening works. We start with some types for which we need no further |
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 <dirent.h> | |
#include <errno.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
int findUp(char* cwd, const char* needle, unsigned char typ); | |
void findDown(char* cwd, const char* needle, unsigned char typ, char* out); |
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 BangPatterns #-} | |
{-# LANGUAGE NoMonomorphismRestriction #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
module Main where | |
import Data.Functor.Identity | |
import Data.Monoid |
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 DataKinds #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeFamilyDependencies #-} | |
{-# LANGUAGE TypeInType #-} |
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
{------------------------------------------------------------------------------- | |
Discussion of ContT in terms of callbacks | |
For an alternative exposition, see | |
<http://www.haskellforall.com/2012/12/the-continuation-monad.html>. | |
-------------------------------------------------------------------------------} | |
{-# OPTIONS_GHC -Wall #-} | |
import Control.Exception |
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 RankNTypes #-} | |
{-# LANGUAGE RecordWildCards #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
-- | Error handling | |
-- | |
-- Intended for qualified import | |
-- | |
-- > import Ouroboros.Storage.Util.ErrorHandling (ErrorHandling(..)) | |
-- > import qualified Ouroboros.Storage.Util.ErrorHandling as EH |
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
-- | Convert 'Double' to fixed precision | |
-- | |
-- For precision 'E1', we have | |
-- | |
-- > 1.000 1.010 1.040 1.049 1.050 1.051 1.090 1.100 | |
-- > floor | 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.1 | |
-- > round | 1.0 1.0 1.0 1.0 1.0(*) 1.1 1.1 1.1 | |
-- > ceiling | 1.0 1.1 1.1 1.1 1.1 1.1 1.1 1.1 | |
-- | |
-- (*): See <https://en.wikipedia.org/wiki/IEEE_754#Rounding_rules> |
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 RankNTypes #-} | |
{-# OPTIONS_GHC -Wall #-} | |
import Control.Monad.Reader | |
import Data.Coerce | |
import Test.QuickCheck.Gen | |
import Test.QuickCheck.Monadic |