Skip to content
/ Named Public

Associate type-level names to values in a heterogeneous non-empty list

Notifications You must be signed in to change notification settings

syallop/Named

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Associate type-level names (using GHC.TypeLits (Symbol)) to values in a heterogeneous non-empty list.

Example:

let -- Some values
    f b = if b then 'a' else 'z'
    b   = True

    -- Associate type-level Names with values
    namedF = Named (Name :: Name "fName", f)
    namedB = Named (Name :: Name "bName", b)

    -- Create a hetrogeneous non-empty list of named values
    -- nameds :: Nameds '[Named "fName" (Bool -> Char), Named "bName" Bool]
    nameds = namedF `And` (One namedB)

   -- Lookup and work with values by their type-level Name.
   in let f = lookupNamed nameds (Name :: Name "fName")
          b = lookupNamed nameds (Name :: Name "bName")
         in f b
> 'a'

I do not recall what I hoped to do with this.

About

Associate type-level names to values in a heterogeneous non-empty list

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published