blob: 0f99b554b0b5b67bd895b630041614145ba5fa6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
{-# LANGUAGE OverloadedStrings #-}
module Model.Perfume
( Perfume(..)
, csvPerfumes
, getCommonPerfumes
) where
import Data.Text (Text)
import qualified Data.Text as T
import Model.URL
import CSV
data Perfume = Perfume
{ name :: Text
, url :: URL
} deriving (Eq, Show)
csvPerfumes :: [Perfume] -> Text
csvPerfumes = getCsv . map (\perfume -> [name perfume, url perfume])
getCommonPerfumes :: [[Perfume]] -> [Perfume]
getCommonPerfumes (perfumes1:perfumesSequences) =
filter
(\p1 ->
all
(\perfumes2 ->
any
(\p2 -> name p1 == name p2)
perfumes2
)
perfumesSequences
)
perfumes1
|