structs 0.1.2 → 0.1.3
raw patch · 6 files changed
+34/−29 lines, 6 files
Files
- .hlint.yaml +8/−0
- CHANGELOG.markdown +4/−0
- HLint.hs +0/−8
- src/Data/Struct/Internal/Order.hs +1/−1
- structs.cabal +4/−3
- tests/unit.hs +17/−17
+ .hlint.yaml view
@@ -0,0 +1,8 @@+- arguments: [--cpp-define=HLINT, --cpp-ansi]++- ignore: {name: Reduce duplication}+- ignore: {name: Redundant lambda}+- ignore: {name: Use >=>}+- ignore: {name: Use const}+- ignore: {name: Use module export list}+- ignore: {name: Use newtype instead of data}
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+## 0.1.3 [2020.01.29]+* Achieve forward compatibility with+ [GHC proposal 229](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0229-whitespace-bang-patterns.rst).+ ## 0.1.2 [2019.05.02] * Add a unit test suite.
− HLint.hs
@@ -1,8 +0,0 @@-import "hint" HLint.HLint--ignore "Reduce duplication"-ignore "Redundant lambda"-ignore "Use >=>"-ignore "Use const"-ignore "Use module export list"-ignore "Use newtype instead of data"
src/Data/Struct/Internal/Order.hs view
@@ -60,7 +60,7 @@ prev = slot 3 {-# INLINE prev #-} -parent :: Slot (Order a) Label +parent :: Slot (Order a) Label parent = slot 4 {-# INLINE parent #-}
structs.cabal view
@@ -1,6 +1,6 @@ name: structs category: Data-version: 0.1.2+version: 0.1.3 license: BSD3 cabal-version: 1.22 license-file: LICENSE@@ -16,13 +16,14 @@ , GHC == 8.4.4 , GHC == 8.6.5 , GHC == 8.8.1+ , GHC == 8.10.1 synopsis: Strict GC'd imperative object-oriented programming with cheap pointers. description: This project is an experiment with a small GC'd strict mutable imperative universe with cheap pointers inside of the GHC runtime system. extra-source-files:+ .hlint.yaml CHANGELOG.markdown- HLint.hs README.markdown Warning.hs @@ -45,7 +46,7 @@ build-depends: base >= 4.9 && < 5, deepseq,- template-haskell >= 2.11 && < 2.15,+ template-haskell >= 2.11 && < 2.17, ghc-prim, primitive
tests/unit.hs view
@@ -22,7 +22,7 @@ makeStruct [d| data TupleInts a s = TupleInts { tupleLeft, tupleRight :: a- } + } |] -- Create a new tuple of ints@@ -48,16 +48,16 @@ -- Make an empty linked list mkEmptyLinkedList :: LinkedList a s-mkEmptyLinkedList = Nil +mkEmptyLinkedList = Nil -- Make a linked list node with a value mkLinkedListNode :: PrimMonad m => a -> m (LinkedList a (PrimState m)) mkLinkedListNode a = newLinkedList a Nil -- Append a node to a linked list.-appendLinkedList :: PrimMonad m => - LinkedList x (PrimState m) - -> x +appendLinkedList :: PrimMonad m =>+ LinkedList x (PrimState m)+ -> x -> m (LinkedList x (PrimState m)) appendLinkedList xs x = do isend <- isNil <$> (get next xs)@@ -77,7 +77,7 @@ -- Convert a haskell list to a linked list listToLinkedList :: PrimMonad m => [a] -> m (LinkedList a (PrimState m))-listToLinkedList [] = return mkEmptyLinkedList +listToLinkedList [] = return mkEmptyLinkedList listToLinkedList (x:xs) = do head <- mkLinkedListNode x rest <- listToLinkedList xs@@ -88,16 +88,16 @@ -- TODO: setup ViewPatterns to check when something is nil -- concat xs ys == xs := xs ++ ys-concatLinkedList :: PrimMonad m => - LinkedList a (PrimState m) - -> LinkedList a (PrimState m) +concatLinkedList :: PrimMonad m =>+ LinkedList a (PrimState m)+ -> LinkedList a (PrimState m) -> m () concatLinkedList xs ys =- if isNil xs + if isNil xs then error "head of list is undefined"- else do + else do isend <- isNil <$> (get next xs)- if isend + if isend then set next xs ys else get next xs >>= \xs' -> concatLinkedList xs' ys @@ -129,12 +129,12 @@ qcProps = testGroup "(checked by QuickCheck)"- [ QC.testProperty @ ([Int] -> Bool) "list to linked list" $ + [ QC.testProperty @([Int] -> Bool) "list to linked list" $ \xs -> runST $ do lxs <- listToLinkedList xs listEqLinkedList xs lxs - , QC.testProperty @ (NonEmptyList Int -> Bool) "Indexing linked lists" $ + , QC.testProperty @(NonEmptyList Int -> Bool) "Indexing linked lists" $ \xs -> runST $ do lxs <- listToLinkedList (getNonEmpty xs) @@ -144,11 +144,11 @@ -- return $ getNonEmpty lxs == xsAtIx - , QC.testProperty @ (NonEmptyList Int -> [Int] -> Bool) "Appending linked lists" $ + , QC.testProperty @(NonEmptyList Int -> [Int] -> Bool) "Appending linked lists" $ \xs ys -> runST $ do lxs <- listToLinkedList (getNonEmpty xs) lys <- listToLinkedList ys- + -- this mutates lxs concatLinkedList lxs lys @@ -166,7 +166,7 @@ unitTests = testGroup "Unit tests"- [ testCase "create and get value from tuple" $ + [ testCase "create and get value from tuple" $ runST $ do c <- mkTupleInts 10 20 val <- getTupleLeft c