Trying an example from split docs:
$ stack ghci
...
Prelude> :set -XOverloadedStrings
Prelude> import qualified RIO.ByteString as B
Prelude B> B.split 'a' "aXaXaXa"
<interactive>:3:9: error:
• Couldn't match expected type ‘GHC.Word.Word8’
with actual type ‘Char’
• In the first argument of ‘B.split’, namely ‘'a'’
In the expression: B.split 'a' "aXaXaXa"
In an equation for ‘it’: it = B.split 'a' "aXaXaXa"
What am I missing?
The documentation is taken from the
split :: Char -> ByteString -> [ByteString]
function of theData.ByteString.Char8
module. This uses the code points 0-255 asChar
for the corresponding byte.You can however use the byte value instead. For example
'a'
has as byte value 97, so we can split this with: