Skip to content

Char constructor is unsafe #24

@brainrake

Description

@brainrake

It shouldn't be exported. But there are no Char literals, so to construct a Char you need to use one of

  • fromCharCode 99
  • fromMaybe (fromCharCode 0) with (charAt 0 "c") or (head $ toCharArray "c") or similar
  • Data.String.Unsafe.charAt 0 "c"
    all of which are somewhat awkward. The first two are safe but obfuscated, the third is unsafe, but at least marked as such.

Lacking character literals, I propose to hide the Char constructor and instead provide Data.String.Unsafe.char :: String -> Char. I can PR if this makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions