Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.
GHC.TypeLits Data.Ord> :k! CmpSymbol "a" "\000" CmpSymbol "a" "\000" :: Ordering = 'LT GHC.TypeLits Data.Ord> compare "a" "\000" GT
???
Tracking this down through GHC, it seems like it ends up being ByteString comparison (inside of FastString) - but
ByteString
FastString
Data.ByteString Data.Ord> compare @ByteString "a" "\000" GT
Could it be something stupid like the arguments are flipped?
Data.ByteString Data.Ord GHC.TypeLits> :k! CmpSymbol "a" "b" CmpSymbol "a" "b" :: Ordering = 'LT Data.ByteString Data.Ord GHC.TypeLits> compare @ByteString "a" "b" LT
Hmmm I wonder if "\000" is getting interpreted differently
Like for CmpSymbol it's the null character but for compare it's "\" followed by "0"s
Although, looking at an ascii table they're both LT 'a'
"\0" behaves the same way And
"\0"
λ> symbolVal $ Proxy @"\0" "\NUL"
Think you have a bug on your hands
But I have no idea how can it arise :sweat_smile:
Just for completeness:
λ> :k! CmpSymbol "a" "\NUL" CmpSymbol "a" "\NUL" :: Ordering = 'LT
That's also wrong, right? :sweat_smile:
Nice: https://gitlab.haskell.org/ghc/ghc/-/issues/18562#note_293330
awesome
You're doing hero work
Thanks to @hsyl20 for tackling this quickly
???
Tracking this down through GHC, it seems like it ends up being
ByteString
comparison (inside ofFastString
) - butCould it be something stupid like the arguments are flipped?
Hmmm I wonder if "\000" is getting interpreted differently
Like for CmpSymbol it's the null character but for compare it's "\" followed by "0"s
Although, looking at an ascii table they're both LT 'a'
"\0"
behaves the same wayAnd
Think you have a bug on your hands
But I have no idea how can it arise :sweat_smile:
Just for completeness:
That's also wrong, right? :sweat_smile:
Nice: https://gitlab.haskell.org/ghc/ghc/-/issues/18562#note_293330
awesome
You're doing hero work
Thanks to @hsyl20 for tackling this quickly