Commit 0b8ca37e authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski Committed by Alexandre Delanoë

[ngrams] throw exception when patch append is not correct

parent a921828a
...@@ -84,6 +84,7 @@ import Data.Traversable (class Traversable, for, sequence, traverse, traverse_) ...@@ -84,6 +84,7 @@ import Data.Traversable (class Traversable, for, sequence, traverse, traverse_)
import Data.TraversableWithIndex (class TraversableWithIndex, traverseWithIndex) import Data.TraversableWithIndex (class TraversableWithIndex, traverseWithIndex)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Exception.Unsafe (unsafeThrow)
import Foreign.Object as FO import Foreign.Object as FO
import Gargantext.Components.Table as T import Gargantext.Components.Table as T
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
...@@ -341,6 +342,7 @@ derive instance eqReplace :: Eq a => Eq (Replace a) ...@@ -341,6 +342,7 @@ derive instance eqReplace :: Eq a => Eq (Replace a)
instance semigroupReplace :: Eq a => Semigroup (Replace a) where instance semigroupReplace :: Eq a => Semigroup (Replace a) where
append Keep p = p append Keep p = p
append p Keep = p append p Keep = p
append (Replace { old }) (Replace { new }) | old /= new = unsafeThrow "old != new"
append (Replace { new }) (Replace { old }) = replace old new append (Replace { new }) (Replace { old }) = replace old new
instance semigroupMonoid :: Eq a => Monoid (Replace a) where instance semigroupMonoid :: Eq a => Monoid (Replace a) where
...@@ -467,6 +469,7 @@ instance monoidPatchMap :: (Ord k, Eq p, Monoid p) => Monoid (PatchMap k p) wher ...@@ -467,6 +469,7 @@ instance monoidPatchMap :: (Ord k, Eq p, Monoid p) => Monoid (PatchMap k p) wher
mempty = PatchMap Map.empty mempty = PatchMap Map.empty
derive instance newtypePatchMap :: Newtype (PatchMap k p) _ derive instance newtypePatchMap :: Newtype (PatchMap k p) _
derive instance eqPatchMap :: (Eq k, Eq p) => Eq (PatchMap k p)
_PatchMap :: forall k p. Iso' (PatchMap k p) (Map k p) _PatchMap :: forall k p. Iso' (PatchMap k p) (Map k p)
_PatchMap = _Newtype _PatchMap = _Newtype
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment