extensible

型レベルリストを作る

{-# LANGUAGE DataKinds         #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications  #-}
{-# LANGUAGE TypeOperators     #-}
module A where

import Data.Extensible
import Data.Functor.Identity
import Data.String
import Data.Text

type T = Record Fields
type Fields = 
  '[ "a" >: Text
   , "b" >: Text
   , "c" >: Text
   ]

r :: T
r = htabulateFor (Proxy @(TargetIs IsString)) $
  wrap . f . getMemberId

f :: IsString p => Int -> p
f 0 = "One"
f 1 = "Two"
f 2 = "Three"

hlint rule

- error: {lhs: Field (Identity x), rhs: wrap x}

参考リソース

Last updated