Skip to content

Instantly share code, notes, and snippets.

🦉
Someone here is possessed by an owl. Who?

Oleg Grenrus phadej

🦉
Someone here is possessed by an owl. Who?
Block or report user

Report or block phadej

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View bar-Bar.hs
{-# LANGUAGE TemplateHaskell #-}
module Bar where
import System.Process (readProcess)
import Control.Monad.IO.Class (liftIO)
import Language.Haskell.TH.Syntax (lift)
fooBar :: String
fooBar = $(liftIO (readProcess "foo" [] "") >>= lift)
View ModelTest.hs
modelTest
:: forall a b f g c.
( c a, c b
, QC.Arbitrary (f b), Eq (g a)
, Show (f a), Show (f b), Show (g a), Show (g b)
, Functor f, Functor g
)
=> (b -> a)
-> Proxy c
-> TestName
View ExceptST.hs
-- this is so wrong.
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MagicHash, UnboxedTuples #-}
{-# LANGUAGE ScopedTypeVariables #-}
module ExceptST (
ExceptST, runExceptST, liftST, throwExceptST,
-- * examples
allNonNegative,
) where
View Unification.hs
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wall #-}
module Unification where
import Control.Monad (ap, forM, forM_)
import Data.Foldable (toList)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
View TypeMap.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
View CabalPlanConvert.hs
class Convert p c | p -> c, c -> p where
toCabal :: p -> c
fromCabal :: c -> p
instance Convert P.Ver C.Version where
toCabal (P.Ver vs) = C.mkVersion vs
fromCabal v = P.Ver (C.versionNumbers v)
instance Convert P.PkgName C.PackageName where
toCabal (P.PkgName n) = C.mkPackageName (T.unpack n)
@phadej
phadej / Inline.hs
Created Aug 1, 2019
Look what I have down. Compare normalFoo and exposeFoo (and inlinableFoo)
View Inline.hs
{-# OPTIONS_GHC -funfolding-creation-threshold=2 #-}
module Inline (inlineFoo, inlinableFoo, exposeFoo, normalFoo) where
import System.IO.Unsafe (unsafePerformIO)
{-
data IfaceUnfolding
= IfCoreUnfold Bool IfaceExpr -- True <=> INLINABLE, False <=> regular unfolding
-- Possibly could eliminate the Bool here, the information
@phadej
phadej / BoolBoolBool.agda
Created Jul 5, 2019
There is one way to equat Unit, and two ways to equat Bool. Counting isomorphisms is fun.
View BoolBoolBool.agda
{-# OPTIONS --safe --cubical #-}
module BoolBoolBool where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Foundations.Isomorphism
View IEnum.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE PolyKinds #-}
@phadej
phadej / Range.hs
Last active Jun 26, 2019
Looks like bitmaskWithRejection is good enough, if the range is small enough. In this completely bogus benchmark.
View Range.hs
-- http://www.pcg-random.org/posts/bounded-rands.html
{-# LANGUAGE CPP, BangPatterns #-}
module Main where
import Data.Bits
import Data.Word (Word32, Word64)
import Data.List (unfoldr)
import qualified System.Random as R
import qualified System.Random.SplitMix32 as SM
You can’t perform that action at this time.