Skip to content

Instantly share code, notes, and snippets.

View kcsongor's full-sized avatar
🤡
':<>:

Csongor Kiss kcsongor

🤡
':<>:
View GitHub Profile
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
@kcsongor
kcsongor / RowToList-tf.hs
Created September 11, 2017 17:03
RowToList with type families
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
@kcsongor
kcsongor / kindclass.hs
Last active December 3, 2017 22:16
some kind classes
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
-- (some examples at the bottom)
import Data.Kind (Constraint, Type)
import GHC.TypeLits (Nat, type (+), type (*))
@kcsongor
kcsongor / natty.hs
Created October 16, 2017 11:55
natty
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
import Control.Lens
--------------------------------------------------------------------------------
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Overlapping where
class C a b where
f :: a -> b -> Bool
instance C a b where
f _ _ = False
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
type family RowToList (r :: * -> *) :: [(Symbol, *)] where
RowToList (l :*: r)
= Merge (RowToList l) (RowToList r)
RowToList (S1 ('MetaSel ('Just name) _ _ _) (Rec0 a))
= '[ '(name, a)]
RowToList (M1 _ m a)
= RowToList a
RowToList _
= '[]
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE TypeFamilies #-}
module BrokenStar where
type family Break a where
Break (a -> b) = (a, b)
broken :: Break (Applicative f => a -> f a)
broken = undefined
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module StrMapRecord where
@kcsongor
kcsongor / OpenKinds.hs
Last active December 26, 2017 22:41
Opening datakinds
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module OpenKinds where
import GHC.TypeLits (Nat)
type family Wrap :: k -> k