Skip to content

Instantly share code, notes, and snippets.

View phadej's full-sized avatar
🦉
Someone here is possessed by an owl. Who?

Oleg Grenrus phadej

🦉
Someone here is possessed by an owl. Who?
View GitHub Profile
import Data.Typeable (Typeable, typeRep)
import Data.Proxy (Proxy (..))
import Text.Read (readMaybe)
import GHC.Stack (HasCallStack)
import Prelude hiding (read)
read :: forall a. (Typeable a, Read a, HasCallStack) => String -> a
read s = case readMaybe s of
Just x -> x
{-# LANGUAGE DeriveFunctor #-}
-- This are are fine
newtype F a = F ((a -> Bool) -> Bool) deriving Functor
newtype T a = T (a,a,a) deriving Functor
-- but if we define
newtype Fun a b = Fun (a -> b) -- and
data Tri a b c = Tri a b c
module Main (main) where
import System.FilePath.Glob (glob)
import Control.Monad (foldM)
import Distribution.Simple.Utils (fromUTF8BS)
import qualified Data.ByteString as BS
import qualified Data.Map.Strict as Map
import GHC.Hs.Expr
[polinukli] ~ % ghc-pkg list --package-db=/cabal/store/ghc-8.6.5/package.db|grep hashable
hashable-1.2.7.0
hashable-1.2.7.0
hashable-1.2.7.0
hashable-1.2.7.0
hashable-1.2.7.0
hashable-1.2.7.0
hashable-1.2.7.0
hashable-1.2.7.0
hashable-1.2.7.0

First build:

% cabal v2-build -w ghc-8.8.3

(I tried at v2.6 tag)

Then run test

{-# 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)
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
@phadej
phadej / ExceptST.hs
Last active November 24, 2019 16:37
-- this is so wrong.
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MagicHash, UnboxedTuples #-}
{-# LANGUAGE ScopedTypeVariables #-}
module ExceptST (
ExceptST, runExceptST, liftST, throwExceptST,
-- * examples
allNonNegative,
) where
{-# 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
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}