fixed hamming code attribute names
This commit is contained in:
parent
36bc32a688
commit
633a1b7b24
|
@ -30,6 +30,7 @@ module Hamming.App.Widgets (
|
|||
-- ** Attribute Names
|
||||
hammingAttr,
|
||||
marginAttr,
|
||||
bodyAttr,
|
||||
checkAttr,
|
||||
zeroAttr,
|
||||
) where
|
||||
|
|
|
@ -35,6 +35,7 @@ module Hamming.App.Widgets.Internal (
|
|||
-- ** Attribute Names
|
||||
hammingAttr,
|
||||
marginAttr,
|
||||
bodyAttr,
|
||||
checkAttr,
|
||||
zeroAttr,
|
||||
) where
|
||||
|
@ -48,7 +49,7 @@ import Hamming.App.Types
|
|||
|
||||
hammingW' :: AppState -> [[(AttrName, Char)]]
|
||||
hammingW' state = let
|
||||
header = (mempty, ' ') : map (marginAttr,) ['0'..'3']
|
||||
header = (hammingAttr, ' ') : map (marginAttr,) ['0'..'3']
|
||||
body = hammingBody state
|
||||
in header : zipWith
|
||||
(\n row -> (marginAttr, n) : row)
|
||||
|
@ -61,8 +62,11 @@ hammingAttr = attrName "hamming"
|
|||
marginAttr :: AttrName
|
||||
marginAttr = hammingAttr <> attrName "margin"
|
||||
|
||||
bodyAttr :: AttrName
|
||||
bodyAttr = hammingAttr <> attrName "body"
|
||||
|
||||
checkAttr :: AttrName
|
||||
checkAttr = hammingAttr <> attrName "check"
|
||||
checkAttr = bodyAttr <> attrName "check"
|
||||
|
||||
zeroAttr :: AttrName
|
||||
zeroAttr = checkAttr <> attrName "zero"
|
||||
|
@ -82,22 +86,22 @@ hammingBody state = let
|
|||
[ [ ( zeroAttr, 0x0001 )
|
||||
, ( checkAttr, 0x0002 )
|
||||
, ( checkAttr, 0x0004 )
|
||||
, ( mempty, 0x0008 )
|
||||
, ( bodyAttr, 0x0008 )
|
||||
]
|
||||
, [ ( checkAttr, 0x0010 )
|
||||
, ( mempty, 0x0020 )
|
||||
, ( mempty, 0x0040 )
|
||||
, ( mempty, 0x0080 )
|
||||
, ( bodyAttr, 0x0020 )
|
||||
, ( bodyAttr, 0x0040 )
|
||||
, ( bodyAttr, 0x0080 )
|
||||
]
|
||||
, [ ( checkAttr, 0x0100 )
|
||||
, ( mempty, 0x0200 )
|
||||
, ( mempty, 0x0400 )
|
||||
, ( mempty, 0x0800 )
|
||||
, ( bodyAttr, 0x0200 )
|
||||
, ( bodyAttr, 0x0400 )
|
||||
, ( bodyAttr, 0x0800 )
|
||||
]
|
||||
, [ ( mempty, 0x1000 )
|
||||
, ( mempty, 0x2000 )
|
||||
, ( mempty, 0x4000 )
|
||||
, ( mempty, 0x8000 )
|
||||
, [ ( bodyAttr, 0x1000 )
|
||||
, ( bodyAttr, 0x2000 )
|
||||
, ( bodyAttr, 0x4000 )
|
||||
, ( bodyAttr, 0x8000 )
|
||||
]
|
||||
]
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ hammingW'Spec = describe "hammingW'" $ mapM_
|
|||
] where
|
||||
mkState c = initialState & hammingCode .~ c
|
||||
allZero =
|
||||
[ [ ( mempty, ' ' )
|
||||
[ [ ( hammingAttr, ' ' )
|
||||
, ( marginAttr, '0' )
|
||||
, ( marginAttr, '1' )
|
||||
, ( marginAttr, '2' )
|
||||
|
@ -75,29 +75,29 @@ hammingW'Spec = describe "hammingW'" $ mapM_
|
|||
, ( zeroAttr, '0' )
|
||||
, ( checkAttr, '0' )
|
||||
, ( checkAttr, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
]
|
||||
, [ ( marginAttr, '1' )
|
||||
, ( checkAttr, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
]
|
||||
, [ ( marginAttr, '2' )
|
||||
, ( checkAttr, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
]
|
||||
, [ ( marginAttr, '3' )
|
||||
, ( mempty, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
]
|
||||
]
|
||||
allOne =
|
||||
[ [ ( mempty, ' ' )
|
||||
[ [ ( hammingAttr, ' ' )
|
||||
, ( marginAttr, '0' )
|
||||
, ( marginAttr, '1' )
|
||||
, ( marginAttr, '2' )
|
||||
|
@ -106,30 +106,30 @@ hammingW'Spec = describe "hammingW'" $ mapM_
|
|||
, [ ( marginAttr, '0' )
|
||||
, ( zeroAttr, '1' )
|
||||
, ( checkAttr, '1' )
|
||||
, ( checkAttr, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( checkAttr , '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
]
|
||||
, [ ( marginAttr, '1' )
|
||||
, ( checkAttr, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
]
|
||||
, [ ( marginAttr, '2' )
|
||||
, ( checkAttr, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
]
|
||||
, [ ( marginAttr, '3' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
]
|
||||
]
|
||||
arbitrary =
|
||||
[ [ ( mempty, ' ' )
|
||||
[ [ ( hammingAttr, ' ' )
|
||||
, ( marginAttr, '0' )
|
||||
, ( marginAttr, '1' )
|
||||
, ( marginAttr, '2' )
|
||||
|
@ -139,25 +139,25 @@ hammingW'Spec = describe "hammingW'" $ mapM_
|
|||
, ( zeroAttr, '0' )
|
||||
, ( checkAttr, '1' )
|
||||
, ( checkAttr, '0' )
|
||||
, ( mempty, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
]
|
||||
, [ ( marginAttr, '1' )
|
||||
, ( checkAttr, '1' )
|
||||
, ( mempty, '0' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '0' )
|
||||
]
|
||||
, [ ( marginAttr, '2' )
|
||||
, ( checkAttr, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( bodyAttr, '0' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
]
|
||||
, [ ( marginAttr, '3' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '1' )
|
||||
, ( mempty, '0' )
|
||||
, ( mempty, '0' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '1' )
|
||||
, ( bodyAttr, '0' )
|
||||
, ( bodyAttr, '0' )
|
||||
]
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user