I am new to Haskell and am attempting to write a function to determine if a string has unique characters. I have the following F# code:
// assume non-null string and all chars are in ASCII range (0-127)
let isUniqueChars (s: string) : bool =
if String.length s <= 1 then
true
elif String.length s > 128 then
false
else
let alphabet = Array.zeroCreate 128
let rec loop i =
if i < String.length s then
let c = s.[i] |> int
if alphabet.[c] then
false
else
alphabet.[c] <- true
loop (i + 1)
else
true
loop 0
I am not sure how I would write a loop with early exit in Haskell.