Skip to content

Instantly share code, notes, and snippets.

View supki's full-sized avatar
🇦🇲
🤝 🏳️‍🌈

Matvey Aksenov supki

🇦🇲
🤝 🏳️‍🌈
  • Gorgoroth, Mordor
View GitHub Profile
>>> data M a = M (Proxy M)
<interactive>:21:12: error:
• Data constructor ‘M’ has existential type variables, a context, or a specialised result type
M :: forall k (a :: k) k. Proxy (k -> *) (M k) -> M k a
(Use ExistentialQuantification or GADTs to allow this)
• In the definition of data constructor ‘M’
In the data type declaration for ‘M’
@supki
supki / stack.hs
Created November 7, 2015 14:56
Example from Chapter 2 of CPDT in modern Haskell
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}
module Main (main) where
@supki
supki / MOSHCH
Created September 17, 2014 06:55
M
% dir=$(mktemp -d); ls .cabal-sandbox/x86_64-linux-ghc-7.8.3-packages.conf.d | grep -P '([\w-]+-[\d.]+)' -o | while read P; do T=$(grep -P '([\w-]+)(?=-[\d.]+)' -o <<< $P); wget --quiet https://hackage.haskell.org/package/$P/$T.cabal -P $dir; done; .cabal-sandbox/bin/outdated $dir/*.cabal; rm -rf $dir
Loading the index.....
‘/tmp/tmp.OAtczPmde5/blaze-builder.cabal’ has outdated dependencies against ‘linux;x86_64;ghc-7.8;’:
- library
the version range of ‘text’ (>=0.10 && <1.2) does not include the latest version 1.2.0.0
‘/tmp/tmp.OAtczPmde5/case-insensitive.cabal’ has outdated dependencies against ‘linux;x86_64;ghc-7.8;’:
- library
the version range of ‘text’ (>=0.3 && <1.2) does not include the latest version 1.2.0.0
- test-suite ‘test-case-insensitive’
the version range of ‘text’ (>=0.3 && <1.2) does not include the latest version 1.2.0.0
@supki
supki / eblo.hs
Created September 9, 2014 21:04
EBLO
newtype FromJSON_ a = FromJSON_ { _parseJSON :: Value -> Parser a }
newtype T a s = T { unT :: a }
instance Reifies s (FromJSON_ a) => FromJSON (T a s) where
parseJSON = fmap T . _parseJSON (reflect (Proxy :: Proxy s))
parseJson :: forall a. (Value -> Parser a) -> ByteString -> Maybe a
parseJson f b = reify (FromJSON_ f) (\(_ :: Proxy s) -> fmap unT ((decode :: ByteString -> Maybe (T a s)) b))
@supki
supki / eblo.rb
Created June 27, 2014 11:46
EBLO
#!/usr/bin/env ruby
def with_sobachka(str, &block)
puts "Sobachka!"
block.call
end
if $0 == __FILE__
with_sobachka(<<-SOBACHKA) do
Eblo = 1
@supki
supki / eblo.hs
Last active August 29, 2015 14:01
Crap
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
@supki
supki / eblo.rb
Created April 18, 2014 12:08
EBLO
class I
attr_accessor :name
def initialize(name)
self.name = name
end
end
class D < I
attr_accessor :children
#!/usr/bin/env bash
set -o errexit
fun-global ()
{
FOO=$(exit 1)
echo "fun-global: this won't be printed"
}
@supki
supki / LazyPatterns.hs
Created February 3, 2014 12:06
An "introduction" to how to make *really* lazy lenses
module LazyPatterns where
import Control.Lens
{-# ANN module "HLint: ignore Use camelCase" #-}
data T = C { _x :: Int, _y :: Char } deriving (Show, Eq)
-- |
module Main (main) where
import Control.Applicative
import Control.Monad
import Data.ByteString (ByteString)
import qualified Data.ByteString as ByteString
import qualified Data.ByteString.Char8 as ByteString (readInt)
import qualified Data.ByteString.Unsafe as ByteString
import qualified Data.HashMap.Strict as Map
import Data.Char (ord)