Skip to content

Rename Symbol to String #3103

@kcsongor

Description

@kcsongor

Symbols behave exactly like Strings at the type-level. Imagining a future where PureScript has datatype-promotion with potentially function promotion as well (much like the singletons library for Haskell), the fact that these are called differently will likely cause issues, or at least confusion.

What this means in Haskell today, is that data-types that use either Symbol or String can only be used at their respected levels. In other words, Symbols can only be promoted, and Strings must be values. The following snippet demonstrates the issue:

{-# LANGUAGE DataKinds      #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds      #-}

module SymbolString where

import GHC.TypeLits

data D1 = D1 String

data D2 = D2 Symbol

data Proxy (a :: k) = Proxy

d1 :: D1
d1 = D1 "foo"


-- Doesn't work:
--d1' :: Proxy ('D1 "foo")
--d1' = Proxy
--
--    • Expected kind ‘String’, but ‘"foo"’ has kind ‘Symbol’

d2 :: Proxy ('D2 "foo")
d2 = Proxy

'D1 has no type-level inhabitants, and D2 has no value-level inhabitants. singletons solves this issue by special-casing String, but I think that's not very elegant.

If datatype-promotion is a planned feature, then I think renaming Symbol to String would make sense sooner rather than later.

Because this would break a lot of existing code, maybe some temporary kind synonym can be introduced that throws a warning?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions