Skip to content

Instantly share code, notes, and snippets.

@alpmestan
alpmestan / ghc.diff
Created October 7, 2017 00:39
Adding :kind!! to ghci, for expanding type families _AND_ type synonyms
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 32e581a10d..b320ef42ce 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -76,6 +76,7 @@ import Linker
import Maybes ( orElse, expectJust )
import NameSet
import Panic hiding ( showException )
+import Type ( expandTypeSynonyms )
import Util

Keybase proof

I hereby claim:

  • I am alpmestan on github.
  • I am alpmestan (https://keybase.io/alpmestan) on keybase.
  • I have a public key ASD90e7ZU64oz5bgOCJwgXqRtDML5sYiQk_FY0bxl3IyMwo

To claim this, I am signing this object:

@alpmestan
alpmestan / bla.sh
Created September 11, 2017 08:48
styx
cabal install styx
Warning: The package list for 'hackage.haskell.org' is 26 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Configuring conduit-1.2.11...
Building conduit-1.2.11...
Installed conduit-1.2.11
Configuring yaml-0.8.23.3...
Building yaml-0.8.23.3...
Installed yaml-0.8.23.3
@alpmestan
alpmestan / coyo.hs
Last active August 4, 2019 13:54
Coyoneda lemma & fmap fusion
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
import Data.Monoid
import System.Environment
data Coyoneda f a where
Coyoneda :: (b -> a) -> f b -> Coyoneda f a
-- similar to https://ghc.haskell.org/trac/ghc/ticket/12468
-- except that I'm trying with 8.2.1
GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help
Prelude> :set -XGADTs
Prelude> data Foo a where Foo :: Int -> Foo Bool
Prelude> f :: Foo a -> a ; f (Foo n) = _k n
<interactive>:3:31: error:
Found hole: _k :: Int -> a
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Proxy
-- could probably use 'reflection' instead of my
-- hacky KnownXXX classes
@alpmestan
alpmestan / Files.hs
Last active August 17, 2016 23:53
File upload with servant
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeSynonymInstances #-}
module Files where
import Control.Monad.IO.Class
import Control.Monad.Trans.Either
@alpmestan
alpmestan / gist:33b756b790fbf2c8d2ca
Created January 16, 2015 02:47
pure-darwin openssh/openssl error
checking OpenSSL header version... 100010bf (OpenSSL 1.0.1k 8 Jan 2015)
checking OpenSSL library version... 100010af (OpenSSL 1.0.1j 15 Oct 2014)
checking whether OpenSSL's headers match the library... no
configure: error: Your OpenSSL headers do not match your
library. Check config.log for details.
If you are sure your installation is consistent, you can disable the check
by running "./configure --without-openssl-header-check".
Also see contrib/findssl.sh for help identifying header/library mismatches.
builder for ‘/nix/store/qx4hpp9h9zk0cqldkv51avc9hwg6l4n5-openssh-6.7p1.drv’ failed with exit code 1
@alpmestan
alpmestan / crud.hs
Created December 31, 2014 17:43
reusable operations, in servant 0.2
--
type CRUD (resourceName :: Symbol) i a =
resourceName :> Get [a] -- optional: list all
:<|> resourceName :> ReqBody a :> Post a -- create
:<|> resourceName :> Capture "id" i :> Get a -- read
:<|> resourceName :> Capture "id" i :> ReqBody a :> Put a -- update
:<|> resourceName :> Capture "id" i :> Delete -- delete
module Data.JSON.FromJSON where
import Control.Applicative
import Data.ByteString
import Data.JSON.Stream
newtype Parse a =
Parse { runParse :: [Event] -> Maybe a }
boo :: Parse a