summaryrefslogtreecommitdiff
path: root/testsuite/tests/polykinds/T13659.hs
blob: 118a04f122b6428a1e6de2dba0c42ae6018c6bf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{-# LANGUAGE GADTs, EmptyDataDecls, TypeFamilies, TypeOperators, DataKinds, FlexibleInstances #-}

{- Defines a C-like printf function using DataKinds extensions. -}

module T13659 where

import Data.Kind (Type)

-- format string parameterized by a list of types
data Format (fmt :: [Type]) where
  X :: Format '[]                   -- empty string, i.e. ""
  L :: a -> String -> Format '[]    -- string literal, e.g. "hello"
  S :: a -> Format '[String]        -- "%s"
  I :: Format a -> Format '[Int, a] -- "%d"