This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
import Data.List | |
dict = ['a' .. 'z'] | |
base = length dict + 2 | |
encode :: String -> Int | |
encode = fst . foldl go (0, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Environment | |
import Data.Function | |
main :: IO () | |
main = do | |
path:_ <- getArgs | |
txt <- readFile path | |
print $ fix | |
(\go xs -> case xs of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RankNTypes, TypeInType, TypeOperators, GADTs, TypeFamilies, | |
ConstraintKinds, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts, | |
UndecidableInstances, ScopedTypeVariables, DeriveGeneric #-} | |
-- base | |
import Data.Kind | |
import Data.Proxy | |
import GHC.Generics | |
import GHC.TypeLits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RankNTypes, TypeOperators, TypeInType, GADTs, TypeFamilies, | |
MultiParamTypeClasses, FlexibleContexts, UndecidableInstances, | |
ConstraintKinds, FlexibleInstances #-} | |
-- base | |
import Data.Kind | |
import Data.Proxy | |
import Data.Type.Bool | |
import Data.Type.Equality |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GeneralizedNewtypeDeriving, RankNTypes, TypeInType, TypeFamilies #-} | |
import Control.Monad | |
import Control.Monad.IO.Class | |
import Data.Kind | |
import System.IO | |
type family OnStack (pr :: Type -> Type) (cr :: Type -> Type) where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template <typename C> | |
struct Base | |
{ | |
static const int id; | |
static constexpr const char* const name = 0; | |
static void out(){ std::cout << "name: " << C::name << std::endl; } | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeOperators, TypeInType, GADTs, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts #-} | |
data HList (xs :: [k]) where | |
Z :: HList '[] | |
(:.) :: a -> HList xs -> HList (a ': xs) | |
infixr 5 :. | |
class Filter a xs where | |
typeFilter :: HList xs -> [a] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ExistentialQuantification #-} | |
import Data.Typeable | |
newtype Name = Name { getName :: Name } | |
newtype Phone = Phone { getPhone :: Int } | |
data Selection = Selection Int Int | |
data ExistPhone = forall t. (IsContact t, Typeable t) => MkPhone t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE Rank2Types #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
import Data.Proxy | |
import GHC.TypeLits | |
data A = A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeInType #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE Rank2Types #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE UndecidableInstances #-} |
NewerOlder