3
から定期的にリストを取得する私はあなたが以下のコードで見ることができるようProxy
とnatVal
を使用してInteger
にNat
を変換する方法見つけた:タイプ一覧
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Data.Proxy (Proxy)
import Data.Monoid ((<>))
import GHC.TypeLits
main :: IO()
main = do
fromNat (undefined :: Proxy 5)
fromNat :: KnownNat n => Proxy n -> IO()
fromNat proxy = do
let (num :: Integer) = natVal proxy -- converting a Nat to an Integer
putStrLn $ "Some num: " <> show num
をしかし、私はできませんよ通常のリストにタイプのリストを変換する簡単な方法を考えるために、以下のコードでもチェック入力していません:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Data.Proxy (Proxy)
import Data.Monoid ((<>))
import GHC.TypeLits
main :: IO()
main = do
fromNat (undefined :: Proxy 5)
fromListNat (undefined :: Proxy '[2,3,10])
fromNat :: KnownNat n => Proxy n -> IO()
fromNat proxy = do
let (num :: Integer) = natVal proxy -- converting a Nat to an Integer
putStrLn $ "Some num: " <> show num
fromListNat :: Proxy [Nat] -> IO()
fromListNat = undefined
は、どのように私は、通常のリストにタイプリストを変換することができますか?