Created
October 3, 2024 20:13
-
-
Save evanrelf/45a7cba9f09f9ebef5c7429a3c2d779f to your computer and use it in GitHub Desktop.
More full fledged version here: https://gist.github.com/evanrelf/d6f55a6db6230f4f30b157ad1fb1b61c
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
{-# 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