#Does gleam have a `char` type

1 messages · Page 1 of 1 (latest)

crude knoll
#

I'm trying to mock up antimirov derivatives in Gleam and was wondering if gleam had a type for single length chars?

strange saffron
#

No, it doesn't

#

Well, it sort of does, but not really

#

char doesn't really make sense in the age of unicode

#

There's a Utf8Codepoint type but it's not really what people think of as a character

crude knoll
#

I see

keen lake
#

Nothing stopping you writing your own of course

crude knoll
#

mhmm yeah, just debating whether I want to but it seems to be handy for the derivatives so I'll probably write it up

#

actually dunno how to, don't think constructors can have guard clauses on them can they?

#

or private constructors

#

oh opaque types

keen lake
crude knoll
#

right now I'm trying to figure out how to wire up the creating function

#

how should I represent failure when the condition is met, I dunno if I wanna return a result from the function all the time

strange saffron
#

I'd just use strings, yolo

keen lake
#

yeah, with probably a sprinkle of assert

#

what is it you're making/trying to do?

crude knoll
#

antimirov derivatives, essentially the base for a regex to NFA algo

#

strings are just concatted chars and states rely on single chars for letters

keen lake
#

yeah i would just use String tbh, save the headache

#

at least until the thing works

crude knoll
#

fair

strange saffron
#

Probably want to avoid all the boxing of records for something like regex

crude knoll
#

eh its for construction purposes

#

boils down to an automaton later on

#

shouldnt be too bad