How do I convert a list to a tuple in Haskell?

后端 未结 7 715
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 07:55

How can I best convert a list to a tuple in Haskell:

[1,2,3,4,5,6] -> (1,2,3,4,5,6)
7条回答
  •  心在旅途
    2020-12-01 08:25

    I find it difficult to make cogent explanations of Template Haskell manipulations, but here is a demonstration:

    > :m +Language.Haskell.TH
    > :set -XTemplateHaskell
    > runQ [| [1,2,3,4,5,6] |] >>= putStrLn . pprint
    [1, 2, 3, 4, 5, 6]
    > runQ [| [1,2,3,4,5,6] |] >>= \ (ListE exps) -> putStrLn (pprint (TupE exps))
    (1, 2, 3, 4, 5, 6)
    

提交回复
热议问题