Created
November 22, 2018 10:50
-
-
Save jyrimatti/bd139e91ed257d37bc57c08ac505fc3f to your computer and use it in GitHub Desktop.
Scripting with Nix instead of Cabal (https://gitlab.com/fommil/dotfiles/blob/master/.emacs.d/Main.hs)
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
#! /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