Commit 1b88dd0f authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] G.D.Maybe -> G.D.Array

parent 3ee4bc3e
......@@ -11,7 +11,7 @@ import Data.Tuple.Nested((/\))
import Reactix as R
import Reactix.DOM.HTML as RH
import Gargantext.Data.Maybe (catMaybes)
import Gargantext.Data.Array (catMaybes)
import Gargantext.Components.RandomText (words)
import Gargantext.Components.Nodes.Corpus.Graph.Tabs as GT
import Gargantext.Components.Graph as Graph
......
module Gargantext.Data.Array
where
import Data.Tuple (Tuple(..))
import Data.Array as DA
import Data.Maybe
import Data.Sequence as DS
import Data.Tuple (Tuple(..))
import Prelude (bind, flip, identity, (<<<))
----------------------------------------------------------------------
-- | Split arrays tools
splitEvery :: forall a. Int -> Array a -> Array (Array a)
splitEvery _ [] = []
splitEvery n xs =
......@@ -18,3 +20,20 @@ splitAt n ls = Tuple (DS.toUnfoldable x) (DS.toUnfoldable xs)
where
Tuple x xs = DS.splitAt n (DS.fromFoldable ls)
----------------------------------------------------------------------
-- | Array with Maybe tools
mapMaybe :: forall a b. (a -> Maybe b) -> Array a -> Array b
mapMaybe f = concatMap (maybe [] singleton <<< f)
catMaybes :: forall a. Array (Maybe a) -> Array a
catMaybes = mapMaybe identity
----------------------------------------------------------------------
-- | Array misc tools
concatMap :: forall a b. (a -> Array b) -> Array a -> Array b
concatMap = flip bind
singleton :: forall a. a -> Array a
singleton a = [a]
module Gargantext.Data.Maybe where
import Prelude (bind, flip, identity, (<<<))
import Data.Maybe
mapMaybe :: forall a b. (a -> Maybe b) -> Array a -> Array b
mapMaybe f = concatMap (maybe [] singleton <<< f)
catMaybes :: forall a. Array (Maybe a) -> Array a
catMaybes = mapMaybe identity
concatMap :: forall a b. (a -> Array b) -> Array a -> Array b
concatMap = flip bind
singleton :: forall a. a -> Array a
singleton a = [a]
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