From 59d4e425569af06fe724a5458287b543a6f4d68e Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Fri, 29 Dec 2023 01:30:37 +0300 Subject: [PATCH] Fix the hex representation of data bytes Co-authored-by: Danila Danko --- eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs b/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs index 03b0e5df5..9010d5aee 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs @@ -63,7 +63,17 @@ rule1 (Formation bindings) = do then do nus <- gets totalNuCount modify (\c -> c{totalNuCount = totalNuCount c + 1}) - let dataObject = Formation [DeltaBinding $ Bytes $ showHex nus ""] + let pad s = (if even (length s) then "" else "0") ++ s + let insertDashes s + | length s <= 2 = s ++ "-" + | otherwise = + let go = \case + [] -> [] + [x] -> [x] + [x, y] -> [x, y, '-'] + (x : y : xs) -> x : y : '-' : go xs + in go s + let dataObject = Formation [DeltaBinding $ Bytes $ insertDashes $ pad $ showHex nus ""] pure (AlphaBinding VTX dataObject : normalizedBindings) else do pure normalizedBindings