@@ -2,11 +2,9 @@
22
33module Nock (tar, hax, fas, cell, atom, Annotation (..), Noun, RawNoun (..)) where
44
5−import Control.DeepSeq (force)
6−import Control.Parallel.Strategies
5+import Control.DeepSeq (NFData, force)
76import Data.Bits
87import Data.Hashable
9−import Debug.Trace
108import GHC.Conc (par)
119import GHC.Generics (Generic)
1210import Numeric.Natural
@@ -103,12 +101,12 @@ fas lhs rhs =
103101 else fas 2 rest
104102
105103hax :: Natural -> Noun -> Noun -> Noun
106−hax n b c =
107− let a = unsafeShiftR n 1
108− in case n of
109− 1 -> b
110− _ | testBit n 0 -> hax a (cell (fas (n - 1) c) b) c
111− _ -> hax a (cell b (fas (n + 1) c)) c
104+hax 1 newValue _ = newValue
105+hax place newValue ~(Cell lhs rhs _) =
106+ let a = unsafeShiftR place 1
107+ in if testBit place 0
108+ then cell (hax a newValue lhs) rhs
109+ else cell lhs (hax a newValue rhs)
112110
113111tar :: Noun -> Noun
114112tar ~(Cell subject ~(Cell a b _) _) = tar' a b subject