
#11342: Character kind -------------------------------------+------------------------------------- Reporter: alexvieth | Owner: alexvieth Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: DataKinds Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10776, #12162 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by zyla): I think that using the promoted `Char` datatype is a good idea. I wouldn't however put in all the related type families (`ToUpper`, `IsAlpha` etc). I think it's better to provide type families for converting between `Char` and `Nat`, and let the user implement the needed functions at type level if desired. The motivation is having less code in the compiler. To sum up, my proposal is to have: 1. Promoted `Char` datatype (already there) 2. Character literal syntax in types 3. Type famililes for analyzing/constructing `Symbol`s: {{{ -- Pattern match a Symbol. 'Nothing when empty, 'Just '(head, tail) -- otherwise. type family UnconsSymbol (s :: Symbol) :: Maybe (Character, Symbol) -- Put a Character at the head of a Symbol. type family ConsSymbol (c :: Character) (s :: Symbol) :: Symbol }}} 4. Type families for converting between `Nat` and `Char`: {{{ type family CharToNat (c :: Char) :: Nat type familt NatToChar (n :: Nat) :: Char }}} @alexvieth: Are you planning to work on this? If not, would you mind if I took your patch, implemented the changes mentioned above and posted it to Phab? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11342#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler