packages feed

net-spider 0.2.0.0 → 0.3.0.0

raw patch · 8 files changed

+140/−43 lines, 8 filesdep ~greskellPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: greskell

API changes (from Hackage documentation)

+ NetSpider.Found: instance Data.Bifunctor.Bifunctor (NetSpider.Found.FoundNode n)
+ NetSpider.Found: instance Data.Bifunctor.Bifunctor NetSpider.Found.FoundLink
+ NetSpider.Found: instance GHC.Base.Functor (NetSpider.Found.FoundLink n)
+ NetSpider.Found: instance GHC.Base.Functor (NetSpider.Found.FoundNode n na)
+ NetSpider.Snapshot.Internal: SnapshotLink :: n -> n -> Bool -> Timestamp -> la -> SnapshotLink n la
+ NetSpider.Snapshot.Internal: SnapshotNode :: n -> Bool -> Maybe Timestamp -> Maybe na -> SnapshotNode n na
+ NetSpider.Snapshot.Internal: [_destinationNode] :: SnapshotLink n la -> n
+ NetSpider.Snapshot.Internal: [_isDirected] :: SnapshotLink n la -> Bool
+ NetSpider.Snapshot.Internal: [_isOnBoundary] :: SnapshotNode n na -> Bool
+ NetSpider.Snapshot.Internal: [_linkAttributes] :: SnapshotLink n la -> la
+ NetSpider.Snapshot.Internal: [_linkTimestamp] :: SnapshotLink n la -> Timestamp
+ NetSpider.Snapshot.Internal: [_nodeAttributes] :: SnapshotNode n na -> Maybe na
+ NetSpider.Snapshot.Internal: [_nodeId] :: SnapshotNode n na -> n
+ NetSpider.Snapshot.Internal: [_nodeTimestamp] :: SnapshotNode n na -> Maybe Timestamp
+ NetSpider.Snapshot.Internal: [_sourceNode] :: SnapshotLink n la -> n
+ NetSpider.Snapshot.Internal: data SnapshotLink n la
+ NetSpider.Snapshot.Internal: data SnapshotNode n na
+ NetSpider.Snapshot.Internal: instance (GHC.Classes.Eq n, GHC.Classes.Eq la) => GHC.Classes.Eq (NetSpider.Snapshot.Internal.SnapshotLink n la)
+ NetSpider.Snapshot.Internal: instance (GHC.Classes.Eq n, GHC.Classes.Eq na) => GHC.Classes.Eq (NetSpider.Snapshot.Internal.SnapshotNode n na)
+ NetSpider.Snapshot.Internal: instance (GHC.Classes.Ord n, GHC.Classes.Eq la) => GHC.Classes.Ord (NetSpider.Snapshot.Internal.SnapshotLink n la)
+ NetSpider.Snapshot.Internal: instance (GHC.Classes.Ord n, GHC.Classes.Eq na) => GHC.Classes.Ord (NetSpider.Snapshot.Internal.SnapshotNode n na)
+ NetSpider.Snapshot.Internal: instance (GHC.Show.Show n, GHC.Show.Show la) => GHC.Show.Show (NetSpider.Snapshot.Internal.SnapshotLink n la)
+ NetSpider.Snapshot.Internal: instance (GHC.Show.Show n, GHC.Show.Show na) => GHC.Show.Show (NetSpider.Snapshot.Internal.SnapshotNode n na)
+ NetSpider.Snapshot.Internal: instance Data.Bifunctor.Bifunctor NetSpider.Snapshot.Internal.SnapshotLink
+ NetSpider.Snapshot.Internal: instance Data.Bifunctor.Bifunctor NetSpider.Snapshot.Internal.SnapshotNode
+ NetSpider.Snapshot.Internal: instance GHC.Base.Functor (NetSpider.Snapshot.Internal.SnapshotLink n)
+ NetSpider.Snapshot.Internal: instance GHC.Base.Functor (NetSpider.Snapshot.Internal.SnapshotNode n)
+ NetSpider.Snapshot.Internal: linkNodePair :: SnapshotLink n la -> Pair n
+ NetSpider.Snapshot.Internal: linkNodeTuple :: SnapshotLink n la -> (n, n)
- NetSpider.Found: FoundLink :: !n -> !LinkState -> !la -> FoundLink n la
+ NetSpider.Found: FoundLink :: n -> LinkState -> la -> FoundLink n la
- NetSpider.Found: FoundNode :: !n -> !Timestamp -> ![FoundLink n la] -> !na -> FoundNode n na la
+ NetSpider.Found: FoundNode :: n -> Timestamp -> [FoundLink n la] -> na -> FoundNode n na la
- NetSpider.Found: [foundAt] :: FoundNode n na la -> !Timestamp
+ NetSpider.Found: [foundAt] :: FoundNode n na la -> Timestamp
- NetSpider.Found: [linkAttributes] :: FoundLink n la -> !la
+ NetSpider.Found: [linkAttributes] :: FoundLink n la -> la
- NetSpider.Found: [linkState] :: FoundLink n la -> !LinkState
+ NetSpider.Found: [linkState] :: FoundLink n la -> LinkState
- NetSpider.Found: [neighborLinks] :: FoundNode n na la -> ![FoundLink n la]
+ NetSpider.Found: [neighborLinks] :: FoundNode n na la -> [FoundLink n la]
- NetSpider.Found: [nodeAttributes] :: FoundNode n na la -> !na
+ NetSpider.Found: [nodeAttributes] :: FoundNode n na la -> na
- NetSpider.Found: [subjectNode] :: FoundNode n na la -> !n
+ NetSpider.Found: [subjectNode] :: FoundNode n na la -> n
- NetSpider.Found: [targetNode] :: FoundLink n la -> !n
+ NetSpider.Found: [targetNode] :: FoundLink n la -> n
- NetSpider.Timestamp: Timestamp :: !Int64 -> !Maybe TimeZone -> Timestamp
+ NetSpider.Timestamp: Timestamp :: Int64 -> Maybe TimeZone -> Timestamp
- NetSpider.Timestamp: [epochTime] :: Timestamp -> !Int64
+ NetSpider.Timestamp: [epochTime] :: Timestamp -> Int64
- NetSpider.Timestamp: [timeZone] :: Timestamp -> !Maybe TimeZone
+ NetSpider.Timestamp: [timeZone] :: Timestamp -> Maybe TimeZone
- NetSpider.Unify: LinkSample :: !n -> !n -> !LinkState -> !Timestamp -> !la -> LinkSample n la
+ NetSpider.Unify: LinkSample :: n -> n -> LinkState -> Timestamp -> la -> LinkSample n la
- NetSpider.Unify: [lsLinkAttributes] :: LinkSample n la -> !la
+ NetSpider.Unify: [lsLinkAttributes] :: LinkSample n la -> la
- NetSpider.Unify: [lsLinkState] :: LinkSample n la -> !LinkState
+ NetSpider.Unify: [lsLinkState] :: LinkSample n la -> LinkState
- NetSpider.Unify: [lsSubjectNode] :: LinkSample n la -> !n
+ NetSpider.Unify: [lsSubjectNode] :: LinkSample n la -> n
- NetSpider.Unify: [lsTargetNode] :: LinkSample n la -> !n
+ NetSpider.Unify: [lsTargetNode] :: LinkSample n la -> n
- NetSpider.Unify: [lsTimestamp] :: LinkSample n la -> !Timestamp
+ NetSpider.Unify: [lsTimestamp] :: LinkSample n la -> Timestamp

Files

ChangeLog.md view
@@ -1,5 +1,35 @@ # Revision history for net-spider +## 0.3.0.0  -- 2019-05-03++* Export `Snapshot.Internal` module. This module is only for internal+  use.++* **[BREAKING CHANGE]** Use StrictData extension by default. This changes the strictness of the following data types.++    * `Query` (from Query module)+    * `Config` (from Spider.Config module)+    * `UnifyStdConfig` (from Unify module)++### Found module++* Add `Functor` and `Bifunctor` instances to `FoundNode` and+  `FoundLink.`++### Graph module++* Add `NodeAttributes` instance to `PropertyMapList`.+* Add `LinkAttributes` instance to `PropertyMapSingle`.++### Query module++* **[BREAKING CHANGE]** `Query` data type is now strict.++### Snapshot module++* Add `Functor` and `Bifunctor` instances to `SnapshotNode` and+  `SnapshotLink.`+ ## 0.2.0.0  -- 2018-12-10  * Add `Log` module.
net-spider.cabal view
@@ -1,5 +1,5 @@ name:                   net-spider-version:                0.2.0.0+version:                0.3.0.0 author:                 Toshio Ito <debug.ito@gmail.com> maintainer:             Toshio Ito <debug.ito@gmail.com> license:                BSD3@@ -17,10 +17,11 @@   default-language:     Haskell2010   hs-source-dirs:       src   ghc-options:          -Wall -fno-warn-unused-imports-  -- default-extensions:   +  default-extensions:   StrictData   other-extensions:     OverloadedStrings,                         GeneralizedNewtypeDeriving,-                        TypeFamilies+                        TypeFamilies,+                        FlexibleInstances   exposed-modules:      NetSpider,                         NetSpider.Input,                         NetSpider.Output,@@ -33,9 +34,9 @@                         NetSpider.Graph,                         NetSpider.Pair,                         NetSpider.Query,-                        NetSpider.Log-  other-modules:        NetSpider.Snapshot.Internal,-                        NetSpider.Graph.Internal,+                        NetSpider.Log,+                        NetSpider.Snapshot.Internal+  other-modules:        NetSpider.Graph.Internal,                         NetSpider.Spider.Internal.Graph,                         NetSpider.Spider.Internal.Log,                         NetSpider.Spider.Internal.Spider,@@ -45,7 +46,7 @@                         time >=1.8.0.2 && <1.10,                         vector >=0.12.0.1 && <0.13,                         greskell-websocket >=0.1.1 && <0.2,-                        greskell >=0.2.2 && <0.3,+                        greskell >=0.2.3 && <0.3,                         aeson >=1.2.4 && <1.5,                         safe-exceptions >=0.1.6 && <0.2,                         text >=1.2.2.2 && <1.3,
src/NetSpider/Found.hs view
@@ -13,6 +13,7 @@          linkStateFromText        ) where +import Data.Bifunctor (Bifunctor(..)) import Data.Greskell (FromGraphSON(..)) import Data.Text (Text, unpack) @@ -60,12 +61,22 @@ -- - type @la@: link attributes. data FoundLink n la =   FoundLink-  { targetNode :: !n,-    linkState :: !LinkState,-    linkAttributes :: !la+  { targetNode :: n,+    linkState :: LinkState,+    linkAttributes :: la   }   deriving (Show,Eq,Ord) +-- | @since 0.3.0.0+instance Functor (FoundLink n) where+  fmap f l = l { linkAttributes = f $ linkAttributes l }++-- | @since 0.3.0.0+instance Bifunctor FoundLink where+  bimap fn fla l = l { targetNode = fn $ targetNode l,+                       linkAttributes = fla $ linkAttributes l+                     }+ -- | 'FoundNode' is a node (the subject node) observed at a specific -- time. It has a set of neighbor links found at the moment. --@@ -74,9 +85,19 @@ -- - type @la@: link attributes. data FoundNode n na la =   FoundNode-  { subjectNode :: !n,-    foundAt :: !Timestamp,-    neighborLinks :: ![FoundLink n la],-    nodeAttributes :: !na+  { subjectNode :: n,+    foundAt :: Timestamp,+    neighborLinks :: [FoundLink n la],+    nodeAttributes :: na   }   deriving (Show,Eq)++-- | @since 0.3.0.0+instance Functor (FoundNode n na) where+  fmap f n = n { neighborLinks = (fmap . fmap) f $ neighborLinks n }++-- | @since 0.3.0.0+instance Bifunctor (FoundNode n) where+  bimap fna fla n = n { neighborLinks = (fmap . fmap) fla $ neighborLinks n,+                        nodeAttributes = fna $ nodeAttributes n+                      }
src/NetSpider/Graph/Internal.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE GeneralizedNewtypeDeriving, TypeFamilies, OverloadedStrings #-}+{-# LANGUAGE GeneralizedNewtypeDeriving, TypeFamilies, OverloadedStrings, FlexibleInstances #-} -- | -- Module: NetSpider.Graph.Internal -- Description: @@ -25,8 +25,11 @@     AVertexProperty(..), AVertex(..), AProperty, AEdge(..),     Walk, SideEffect,     Binder, Parser, PropertyMapList, PropertyMapSingle, GValue,-    gIdentity+    gIdentity, gProperty,+    newBind, allProperties, propertyKey, propertyValue   )+import qualified Data.Greskell as Greskell+import Data.Greskell.Extra (writeAllProperties) import Data.Text (Text, unpack) import Data.Time.LocalTime (TimeZone(..)) @@ -57,9 +60,9 @@ -- | The \"found_node\" vertex. data VFoundNode na =   VFoundNode-  { vfnId :: !EID,-    vfnTimestamp :: !Timestamp,-    vfnAttributes :: !na+  { vfnId :: EID,+    vfnTimestamp :: Timestamp,+    vfnAttributes :: na   }   deriving (Show) @@ -105,10 +108,10 @@ -- | \"finds\" edge. data EFinds la =   EFinds-  { efId :: !EID,-    efTargetId :: !EID,-    efLinkState :: !LinkState,-    efLinkAttributes :: !la+  { efId :: EID,+    efTargetId :: EID,+    efLinkState :: LinkState,+    efLinkAttributes :: la   }   deriving (Show) @@ -143,6 +146,14 @@   writeNodeAttributes _ = return gIdentity   parseNodeAttributes _ = return () +-- | Straightforward implementation. Note that 'writeNodeAttributes'+-- does not write meta-properties of the 'AVertexProperty'.+--+-- @since 0.3.0.0+instance (FromGraphSON v, ToJSON v) => NodeAttributes (PropertyMapList AVertexProperty v) where+  writeNodeAttributes = writeAllProperties+  parseNodeAttributes = traverse parseGraphSON+ -- | Class of user-defined types for link attributes. Its content is -- stored in the NetSpider database. class LinkAttributes ps where@@ -155,4 +166,11 @@ instance LinkAttributes () where   writeLinkAttributes _ = return gIdentity   parseLinkAttributes _ = return ()++-- | Straightforward implementation+--+-- @since 0.3.0.0+instance (FromGraphSON v, ToJSON v) => LinkAttributes (PropertyMapSingle AProperty v) where+  writeLinkAttributes = writeAllProperties+  parseLinkAttributes = traverse parseGraphSON   
src/NetSpider/Snapshot/Internal.hs view
@@ -1,9 +1,14 @@ -- | -- Module: NetSpider.Snapshot.Internal--- Description: +-- Description: Implementation of Snapshot graph types -- Maintainer: Toshio Ito <debug.ito@gmail.com> -- -- __this module is internal. End-users should not use this.__+--+-- Implementation of Snapshot graph types. This module is for internal+-- and testing purposes only.+--+-- @since 0.3.0.0 module NetSpider.Snapshot.Internal        ( SnapshotLink(..),          linkNodeTuple,@@ -11,6 +16,7 @@          SnapshotNode(..)        ) where +import Data.Bifunctor (Bifunctor(..)) import NetSpider.Pair (Pair(..)) import NetSpider.Timestamp (Timestamp) @@ -24,11 +30,11 @@ -- - type @la@: link attributes. data SnapshotLink n la =   SnapshotLink-  { _sourceNode :: !n,-    _destinationNode :: !n,-    _isDirected :: !Bool,-    _linkTimestamp :: !Timestamp,-    _linkAttributes :: !la+  { _sourceNode :: n,+    _destinationNode :: n,+    _isDirected :: Bool,+    _linkTimestamp :: Timestamp,+    _linkAttributes :: la          -- Maybe it's a good idea to include 'observationLogs', which can     -- contain warnings or other logs about making this SnapshotLink.@@ -39,6 +45,17 @@ instance (Ord n, Eq la) => Ord (SnapshotLink n la) where   compare l r = compare (linkNodeTuple l) (linkNodeTuple r) +-- | @since 0.3.0.0+instance Functor (SnapshotLink n) where+  fmap f l = l { _linkAttributes = f $ _linkAttributes l }++-- | @since 0.3.0.0+instance Bifunctor SnapshotLink where+  bimap fn fla l = l { _linkAttributes = fla $ _linkAttributes l,+                       _sourceNode = fn $ _sourceNode l,+                       _destinationNode = fn $ _destinationNode l+                     }+ -- | Node-tuple (source node, destination node) of the link. linkNodeTuple :: SnapshotLink n la -> (n, n) linkNodeTuple link = (_sourceNode link, _destinationNode link)@@ -50,13 +67,23 @@ -- | A node in the snapshot graph. data SnapshotNode n na =   SnapshotNode-  { _nodeId :: !n,-    _isOnBoundary :: !Bool,-    _nodeTimestamp :: !(Maybe Timestamp),-    _nodeAttributes :: !(Maybe na)+  { _nodeId :: n,+    _isOnBoundary :: Bool,+    _nodeTimestamp :: Maybe Timestamp,+    _nodeAttributes :: Maybe na   }   deriving (Show,Eq)  -- | Comparison by node ID. instance (Ord n, Eq na) => Ord (SnapshotNode n na) where   compare l r = compare (_nodeId l) (_nodeId r)++-- | @since 0.3.0.0+instance Functor (SnapshotNode n) where+  fmap f n = n { _nodeAttributes = fmap f $ _nodeAttributes n }++-- | @since 0.3.0.0+instance Bifunctor SnapshotNode where+  bimap fn fna n = n { _nodeAttributes = fmap fna $ _nodeAttributes n,+                       _nodeId = fn $ _nodeId n+                     }
src/NetSpider/Spider.hs view
@@ -281,11 +281,11 @@ -- | The state kept while making the snapshot graph. data SnapshotState n na fla =   SnapshotState-  { ssUnvisitedNodes :: !(Queue n),-    ssVisitedNodes :: !(HashMap n (Maybe (VFoundNode na))),+  { ssUnvisitedNodes :: Queue n,+    ssVisitedNodes :: HashMap n (Maybe (VFoundNode na)),     -- ^ If the visited node has no observation yet, its node     -- attributes 'Nothing'.-    ssVisitedLinks :: !(HashMap (LinkSampleID n) [LinkSample n fla])+    ssVisitedLinks :: HashMap (LinkSampleID n) [LinkSample n fla]   }   deriving (Show) 
src/NetSpider/Timestamp.hs view
@@ -41,10 +41,10 @@ -- | Timestamp when graph elements are observed. data Timestamp =   Timestamp-  { epochTime :: !Int64,+  { epochTime :: Int64,     -- ^ Milliseconds since the epoch. The epoch is usually the     -- beginning of year 1970.-    timeZone :: !(Maybe TimeZone)+    timeZone :: Maybe TimeZone   }   deriving (Show,Eq) 
src/NetSpider/Unify.hs view
@@ -44,11 +44,11 @@ -- 'NetSpider.Snapshot.SnapshotLink's. data LinkSample n la =   LinkSample-  { lsSubjectNode :: !n,-    lsTargetNode :: !n,-    lsLinkState :: !LinkState,-    lsTimestamp :: !Timestamp,-    lsLinkAttributes :: !la+  { lsSubjectNode :: n,+    lsTargetNode :: n,+    lsLinkState :: LinkState,+    lsTimestamp :: Timestamp,+    lsLinkAttributes :: la   }   deriving (Show,Eq,Ord)