Skip to content

Instantly share code, notes, and snippets.

@evanrelf
Created October 3, 2024 20:13
Show Gist options
  • Save evanrelf/45a7cba9f09f9ebef5c7429a3c2d779f to your computer and use it in GitHub Desktop.
Save evanrelf/45a7cba9f09f9ebef5c7429a3c2d779f to your computer and use it in GitHub Desktop.
{-# LANGUAGE DataKinds #-}
{-# OPTIONS_GHC -Wall #-}
module X where
import Data.Kind (Type)
import GHC.TypeLits (KnownSymbol, Symbol)
type (:::) :: Symbol -> Type -> Type
data (:::) s a
data Record :: [Type] -> Type where
RNil :: Record '[]
RCons :: KnownSymbol s => a -> Record xs -> Record (s ::: a : xs)
example :: Record '["foo" ::: Float, "bar" ::: Bool]
example =
RCons @"foo" 42.0
$ RCons @"bar" True
$ RNil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment