F# match char values
Posted
by rwallace
on Stack Overflow
See other posts from Stack Overflow
or by rwallace
Published on 2010-05-28T10:45:09Z
Indexed on
2010/05/28
11:02 UTC
Read the original article
Hit count: 144
F#
I'm trying to match an integer expression against character literals, and the compiler complains about type mismatch.
let rec read file includepath =
let ch = ref 0
let token = ref 0
use stream = File.OpenText file
let readch() =
ch := stream.Read()
let lex() =
match !ch with
| '!' ->
readch()
| _ -> token := !ch
ch has to be an int because that's what stream.Read returns in order to use -1 as end of file marker. If I replace '!'
with int '!'
it still doesn't work. What's the best way to do this?
© Stack Overflow or respective owner