This file contains hidden or 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 MagicHash #-} | |
{-# LANGUAGE UnboxedTuples #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeInType #-} | |
-- | Conversion between unlifted and lifted datatypes | |
module Packed.Levity | |
( -- * Types | |
Rep | |
, Levity(..) |
This file contains hidden or 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
hPutMutableByteArray# | |
:: SIO.Handle | |
-> MutableByteArray# RealWorld -- ^ Invariant MUST BE PINNED | |
-> Int# | |
-> State# RealWorld |
This file contains hidden or 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 MagicHash #-} | |
module Strict (idInt, idIntCon) where | |
import GHC.Types | |
idIntCon :: Int -> Int | |
idIntCon (I# x) = (I# x) |
This file contains hidden or 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/sh | |
set -e | |
dir=$(mktemp -d dist-new-docs.XXXXXX) | |
trap 'rm -r "$dir"' EXIT | |
cabal new-haddock --builddir="$dir" --haddock-for-hackage --haddock-option=--hyperlinked-source | |
# Starting with cabal 2.0, `--publish` is needed for uploading to non-candidate releases | |
cabal upload --publish -d $dir/*-docs.tar.gz |
This file contains hidden or 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 Ordered a = Empty | Decreasing a | Increasing a | |
inc :: Ordered a -> Bool | |
inc (Decreasing _) = False | |
inc _ = True | |
dec :: Ordered a -> Bool | |
dec (Increasing _) = False | |
dec _ = True |
This file contains hidden or 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-shell:~/development/nixpkgs]$ nix repl default.nix | |
Welcome to Nix version 2.0.4. Type :? for help. | |
Loading 'default.nix'... | |
Added 9659 variables. | |
nix-repl> :b haskell.compiler.ghcLinear | |
these derivations will be built: | |
/nix/store/pifcl83nn43wkvsdwg1k4m089g44jqvl-hscolour-1.24.4.drv | |
/nix/store/77psczhb9v2j3k2av0pj52vc886v86xm-hscolour-1.24.4.drv |
This file contains hidden or 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
tryAll :: IO a -> IO (Either SomeException a) | |
tryAll = try | |
forkIO_ :: IO () -> IO () | |
forkIO_ x = forkIO x >> pure () | |
foldCommuteIO :: forall t m a. (Foldable t, Monoid m) => (a -> IO m) -> t a -> IO m | |
foldCommuteIO f xs = do | |
var <- newEmptyMVar | |
total <- foldlM (\ !n a -> forkIO_ ( tryAll (f a) >>= putMVar var) >> pure (n + 1)) 0 xs |
This file contains hidden or 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.Functor.Compose | |
doubleFmap :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b) | |
doubleFmap = fmap . fmap | |
fooMonad :: (Monad f, Functor g) => f (a -> b) -> f (g a) -> f (g b) | |
fooMonad fab fga = fab >>= \f -> doubleFmap f fga | |
fooApplicative :: (Applicative f, Applicative g) => f (a -> b) -> f (g a) -> f (g b) | |
fooApplicative fab fga = getCompose (Compose (fmap pure fab) <*> Compose fga) |
This file contains hidden or 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
mkArg :: Int -> String | |
mkArg n = "arg" ++ show n | |
mkDegenerate :: Int -> Int -> String | |
mkDegenerate start end = "f " ++ (mconcat $ intersperse "@" $ map mkArg [start..end]) ++ " = " ++ mkArg end |
This file contains hidden or 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
newtype Branch (o :: OS) e m a = Branch (ExceptT e m a) | |
deriving | |
( Applicative, Eq, Foldable, Functor, Monad, Traversable | |
) | |
branchToExceptT :: Branch o e m a -> ExceptT e m a | |
branchToExceptT = coerce | |