HListを始めようとしています。次の方法で文字列からラベルを生成する方法(関数?)はありますか:
{-# LANGUAGE DataKinds #-}
import Data.HList
lb1 = Label :: Label "myLabel1"
lb2 = Label :: Label "myLabel2"
lb3 = Label :: Label "myLabel3"
myRec = lb1 .=. 'a' .*.
lb2 .=. (True, 42 :: Int) .*.
lb3 .=. 3.14 .*.
emptyRecord
main = do putStrLn "what's the label?"
lb <- getLine -- does not work
putStrLn $ "the value for this label is: " ++ show (myRec .!. lb)
return ()
lb はラベルではなく文字列であるため、このコードはそのままではコンパイルされません。これを達成する適切な方法はありますか?ありがとう。