aboutsummaryrefslogtreecommitdiff
path: root/src/lib/haskell/Model
diff options
context:
space:
mode:
authorJoris2018-06-19 22:49:16 +0200
committerJoris2018-06-19 22:49:16 +0200
commit149a0470b73781022e584aaeaa7ce871d6f4173b (patch)
treec1cc762e105ae19e7f3daaa3e9279a467dbaa3dc /src/lib/haskell/Model
parent5d921c9a2b0a7a8f1a1bb5642cbefa516cbbe4cc (diff)
Add automatic tests on remote pages
Diffstat (limited to 'src/lib/haskell/Model')
-rw-r--r--src/lib/haskell/Model/Ad.hs22
-rw-r--r--src/lib/haskell/Model/URL.hs7
2 files changed, 29 insertions, 0 deletions
diff --git a/src/lib/haskell/Model/Ad.hs b/src/lib/haskell/Model/Ad.hs
new file mode 100644
index 0000000..06906eb
--- /dev/null
+++ b/src/lib/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/lib/haskell/Model/URL.hs b/src/lib/haskell/Model/URL.hs
new file mode 100644
index 0000000..2114113
--- /dev/null
+++ b/src/lib/haskell/Model/URL.hs
@@ -0,0 +1,7 @@
+module Model.URL
+ ( URL
+ ) where
+
+import Data.Text
+
+type URL = Text