lue-bird / elm-morph / Char.Morph

Morph for an elm/core Char

only : Char -> Morph () Char

Match only the specific given broad input. See Morph.only

code : Morph Char Basics.Int

Character by unicode code point

import Morph

Morph.toNarrow Char.Morph.code 65 --> Ok 'A'

Morph.toNarrow Char.Morph.code 66 --> Ok 'B'

Morph.toNarrow Char.Morph.code 0x6728 --> Ok '木'

Morph.toNarrow Char.Morph.code 0x0001D306 --> Ok 'πŒ†'

Morph.toNarrow Char.Morph.code 0x0001F603 --> Ok 'πŸ˜ƒ'

Morph.toNarrow Char.Morph.code -1
--> Err (Morph.DeadEnd "unicode code point outside of range 0 to 0x10FFFF")

The full range of unicode is from 0 to 0x10FFFF. With numbers outside that range, you'll get an error (unlike Char.fromCode).

string : Morph Char String

Morph a String of length 1 to a Char

Be aware, that special-cased characters as the result of Char.toUpper are broadened as 2 Chars in a String and therefore narrowing to a Char will fail.

value : Value.Morph.Internal.MorphValue Char

Char MorphValue

Be aware that special-cased characters as the result of Char.toUpper are broadened as 2 Chars in a Value.String and therefore narrowing to a Char will fail.

bits : MorphRow Char Bit

MorphRow from Bits.

Note that a Char isn't equivalent to a visual unit like πŸ‡¨πŸ‡Ώ or πŸ¦ΈπŸ½β€β™‚οΈ or aΜ΄Μ‰Μ€Μ…Μ«ΜΌΜ« (β†’ see grapheme). Instead, it's just one UTF-8 code point.