Unexpected compile error on type level lists with a single element
Tried this with ghc 8.0.2, 8.2.2 and 8.4.3 and all give an almost identical error on the following piece of code:
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wall #-}
import Data.Singletons.Prelude.List
#if MIN_VERSION_singletons(2,4,0)
type (a :++ b) = a ++ b
#endif
data MyType = A | B | C | D | E | F
type TypeList1 = ['A, 'B]
type TypeList2 = TypeList1 :++ ['C, 'D]
-- Everything above is fine, but this line:
type TypeList3 = TypeList2 :++ ['F]
-- Gives the error:
--
-- type-level-list.hs:21:32: error:
-- • Expected kind ‘[MyType]’, but ‘[ 'F]’ has kind ‘*’
-- • In the second argument of ‘(:++)’, namely ‘[ 'F]’
-- In the type ‘TypeList2 :++ [ 'F]’
-- In the type declaration for ‘TypeList3’
-- |
-- 22 | type TypeList3 = TypeList2 :++ ['F]
-- If instead I write it like:
type TypeList4 = TypeList2 :++ '[F]
-- I get the warning:
--
-- type-level-list.hs:33:34: warning: [-Wunticked-promoted-constructors]
-- Unticked promoted constructor: ‘F’.
-- Use ‘'F’ instead of ‘F’.
-- The following actually seems to work, but I don't understand why type level
-- lists containing only one element are different.
type TypeList5 = TypeList2 :++ '[ 'F]
Trac metadata
Trac field | Value |
---|---|
Version | 8.4.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |