Skip to content

Instantly share code, notes, and snippets.

@jyrimatti
Created November 22, 2018 10:50
Show Gist options
  • Save jyrimatti/bd139e91ed257d37bc57c08ac505fc3f to your computer and use it in GitHub Desktop.
Save jyrimatti/bd139e91ed257d37bc57c08ac505fc3f to your computer and use it in GitHub Desktop.
#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages(p: with p; [type-level-sets])"
#! nix-shell -I nixpkgs=channel:nixos-18.03
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeApplications #-}
module Main where
import Data.Type.Set (Set(..), Proxy(..))
class Get a s where
get :: Set s -> a
instance {-# OVERLAPS #-} Get a (a ': s) where
get (Ext a _) = a
instance {-# OVERLAPPABLE #-} Get a s => Get a (b ': s) where
get (Ext _ xs) = get xs
main :: IO ()
main = do
let lst = Ext "hello" $ Ext 10 $ Empty
putStrLn $ show $ get @String lst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment