aboutsummaryrefslogtreecommitdiff
path: root/src/parser/haskell/Model
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/haskell/Model')
-rw-r--r--src/parser/haskell/Model/Ad.hs22
-rw-r--r--src/parser/haskell/Model/URL.hs7
2 files changed, 29 insertions, 0 deletions
diff --git a/src/parser/haskell/Model/Ad.hs b/src/parser/haskell/Model/Ad.hs
new file mode 100644
index 0000000..06906eb
--- /dev/null
+++ b/src/parser/haskell/Model/Ad.hs
@@ -0,0 +1,22 @@
+module Model.Ad
+ ( Ad(..)
+ , getNewAds
+ ) where
+
+import Data.List ((\\))
+import Data.Text (Text)
+
+import Model.URL (URL)
+
+data Ad = Ad
+ { name :: Text
+ , location :: Text
+ , price :: Maybe Text
+ , url :: URL
+ } deriving (Eq, Read, Show)
+
+getNewAds :: [URL] -> [Ad] -> ([URL], [Ad])
+getNewAds viewdURLs ads =
+ let newURLs = (map url ads) \\ viewdURLs
+ newAds = filter (\ad -> elem (url ad) newURLs) ads
+ in (newURLs, newAds)
diff --git a/src/parser/haskell/Model/URL.hs b/src/parser/haskell/Model/URL.hs
new file mode 100644
index 0000000..2114113
--- /dev/null
+++ b/src/parser/haskell/Model/URL.hs
@@ -0,0 +1,7 @@
+module Model.URL
+ ( URL
+ ) where
+
+import Data.Text
+
+type URL = Text