@@ -2,17 +2,16 @@
3module Nock (tar, hax, fas, cell, atom, Annotation (..), Noun, RawNoun (..)) where
3module Nock (tar, hax, fas, cell, atom, Annotation (..), Noun, RawNoun (..)) where
5+import Control.DeepSeq (NFData)
5import Data.Hashable
6import Data.Hashable
6−import Debug.Trace (trace, traceShowId)
7import GHC.Generics (Generic)
7import GHC.Generics (Generic)
9import Numeric.Natural
8import Numeric.Natural
10−import Test.QuickCheck.Arbitrary.Generic
12data Annotation = Annotation
10data Annotation = Annotation
13 { hash :: Int
11 { hash :: Int
15− deriving stock (Show)
13+ deriving stock (Show, Generic)
14+ deriving anyclass (NFData)
17atom :: Natural -> Noun
16atom :: Natural -> Noun
18atom nat = Atom nat Annotation {hash = hash nat}
17atom nat = Atom nat Annotation {hash = hash nat}
@@ -40,6 +39,7 @@ data RawNoun ann
40 = Atom !Natural ann
39 = Atom !Natural ann
41 | Cell (RawNoun ann) (RawNoun ann) ann
40 | Cell (RawNoun ann) (RawNoun ann) ann
42 deriving stock (Generic, Show)
41 deriving stock (Generic, Show)
42+ deriving anyclass (NFData)
44instance Eq (RawNoun ann) where
44instance Eq (RawNoun ann) where
45 (Atom lhs _) == (Atom rhs _) = lhs == rhs
45 (Atom lhs _) == (Atom rhs _) = lhs == rhs
@@ -70,8 +70,7 @@ fas ~(Cell ~(Atom lhs _) rhs _) =
70 case lhs of
70 case lhs of
72 2 -> case rhs of
72 2 -> case rhs of
73− (Cell lhs' _ _) -> lhs'
73+ ~(Cell lhs' _ _) -> lhs'
75 3 -> case rhs of
74 3 -> case rhs of
76 ~(Cell _ rhs' _) -> rhs'
75 ~(Cell _ rhs' _) -> rhs'