I added OsChar conversions to Witch: Add OsChar conversions by tfausak · Pull Request #158 · tfausak/witch · GitHub
Normally you could use liftedFrom to check values at compile time, like $$(liftedInto @OsChar ‘x’). But unfortunately that won’t work because of a missing Lift instance: Allow lifting OsChar · Issue #44 · haskell/os-string · GitHub
Also note that going through OsString probably won’t do what you want for non-ASCII characters. For example:
ghci> uncons [osstr|λ|]
Just (206,"\187")
You would get '\206’ (U+00CE, LATIN CAPITAL LETTER I WITH CIRCUMFLEX) rather than '\955’ (U+03BB, GREEK SMALL LETTER LAMDA).