Skip to content

Instantly share code, notes, and snippets.

View patrickt's full-sized avatar
🍉

Patrick Thomson patrickt

🍉
View GitHub Profile
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
module Data.Some
( Some (..)
, Some1 (..)
, Any

Benchmarking re. ask

With -O1

Before any optimizations:

benchmarked Control.Carrier.Reader/ask/10
time                 9.877 ns   (9.380 ns .. 10.43 ns)
                     0.985 R²   (0.971 R² .. 0.997 R²)
tr-sttr-0.5.0.0-2ca28879
tr-sttr-0.5.0.0-e60384cd
tr-sttr-g-0.2.0.1-8ca53757
tr-sttr-g-0.2.0.1-396cb03e
tr-sttr-g-0.2.0.1-90280971
tr-sttr-g-0.2.0.1-cb98253a
tr-sttr-jsn-0.3.0.0-5e1d169c
tr-sttr-jsn-0.3.0.0-6dddeb00
tr-sttr-jsn-0.3.0.0-cfda7faf
tr-sttr-jv-0.4.0.0-3db72760
{-# LANGUAGE GeneralizedNewtypeDeriving, MultiParamTypeClasses, ScopedTypeVariables, FlexibleInstances, UndecidableInstances, ExistentialQuantification, TypeApplications, StandaloneDeriving, DeriveFunctor, TypeOperators #-}
module Control.Effect.Random.MWC
( Random (..)
, Control.Effect.Random.MWC.uniform
, Control.Effect.Random.MWC.uniformR
, RandomC (..)
, runRandom
, Variate
, Has
data Separator = Dot | Quest | App
data Access t
= Access Separator (Access t) (Access t)
| Term (t Name)
| Base Name
desugar :: (Monad m, Carrier sig t, Member Core sig) => Access t -> m (t Name)
desugar t = case t of
Access Dot a b -> (Core....) <$> desugar a <*> ensureName b
@patrickt
patrickt / audio.fish
Created September 2, 2019 20:42
fish-shell snippets to convert between representations of lossless audio
function flac_to_m4a
set flacs ./*.flac
if test -z "$flacs"
echo "No .flac files in current directory"
false
else
for flac_path in $flacs
set new_name (basename "$flac_path" .flac).m4a
ffmpeg -i "$flac_path" -c:a alac -c:v copy "$new_name"
Tue Apr 23 17:57 2019 Time and Allocation Profiling Report (Final)
composeconf +RTS -p -RTS
total time = 10.21 secs (10214 ticks @ 1000 us, 1 processor)
total alloc = 19,708,594,272 bytes (excludes profiling overheads)
COST CENTRE MODULE SRC %time %alloc
>>= RWS src/RWS.hs:(28,3)-(30,24) 41.0 4.3
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, TypeOperators, UndecidableInstances, DeriveFunctor, StandaloneDeriving, RankNTypes #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module RWS where
import Control.Applicative
import Control.Effect
import Control.Effect.Carrier
import Control.Effect.Reader
import Control.Effect.State.Internal
{-# LANGUAGE StandaloneDeriving, GeneralizedNewtypeDeriving #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Control.Effect.Parallel.Instances where
import Control.Monad.Parallel
import Control.Effect.Lift
import Control.Effect.Pure
import Control.Effect.State
import Control.Effect.Trace
--import Control.Effect.NonDet
{-# LANGUAGE DeriveFunctor, ExistentialQuantification, FlexibleContexts, StandaloneDeriving, RankNTypes, TypeOperators, FlexibleInstances, TypeFamilies, UndecidableInstances, MultiParamTypeClasses, ScopedTypeVariables, GeneralizedNewtypeDeriving, LambdaCase, TypeApplications #-}
module Control.Effect.Thread where
import Control.Effect
import Control.Effect.Sum
import Control.Effect.Carrier
import Control.Effect.State
import Control.Monad.IO.Class
import Control.Monad.IO.Unlift