Quick actions

cmd+k|ctrl+k

Navigation

Languages

Singleton type example

Snippet info

Language

Haskell

Visibility

public

Author

mindbound

Created

2016-12-08T01:26:22Z

Updated

2016-12-08T01:50:09Z

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ExistentialQuantification #-}

type family Cond (b :: Bool) (t :: k) (e :: k) :: k where
    Cond 'True t e = t
    Cond 'False t e = e

data Booly :: Bool -> * where
    Truey :: Booly 'True
    Falsey :: Booly 'False

item :: forall b . Booly b -> Cond b Int [Int]
item Truey = 42
item Falsey = [1, 2, 3]

main :: IO ()
main = putStrLn $ show $ item Falsey
INFO