ソースを参照

Make ArtDeco stuff functors

jherve 1 年間 前
コミット
af8b4c583d

+ 2 - 0
src/Content.purs

@@ -16,6 +16,7 @@ import LinkedIn.ArtDecoTab (parseArtDecoTab)
 import LinkedIn.JobsUnifiedTopCard (parseJobsUnifiedTopCardElement)
 import LinkedIn.JobsUnifiedTopCard (parseJobsUnifiedTopCardElement)
 import LinkedIn.Profile.Project as PP
 import LinkedIn.Profile.Project as PP
 import LinkedIn.Profile.Skill as PS
 import LinkedIn.Profile.Skill as PS
+import LinkedIn.Profile.Utils (toUIElement)
 import LinkedIn.Profile.WorkExperience as PWE
 import LinkedIn.Profile.WorkExperience as PWE
 import Yoga.Tree (Tree, showTree)
 import Yoga.Tree (Tree, showTree)
 
 
@@ -42,6 +43,7 @@ main = do
       case parsed of
       case parsed of
         Left l -> logShow l
         Left l -> logShow l
         Right p -> do
         Right p -> do
+          logShow $ toUIElement <$> p
           logShow $ PWE.fromUI p
           logShow $ PWE.fromUI p
           logShow $ PP.fromUI p
           logShow $ PP.fromUI p
   case artDecoTabs of
   case artDecoTabs of

+ 17 - 0
src/LinkedIn/ArtDeco.purs

@@ -42,26 +42,43 @@ derive instance Generic (ArtDecoPvsEntitySubComponent a) _
 derive instance Eq a => Eq (ArtDecoPvsEntitySubComponent a)
 derive instance Eq a => Eq (ArtDecoPvsEntitySubComponent a)
 instance Show a => Show (ArtDecoPvsEntitySubComponent a) where
 instance Show a => Show (ArtDecoPvsEntitySubComponent a) where
   show = genericShow
   show = genericShow
+instance Functor ArtDecoPvsEntitySubComponent where
+  map f (ArtDecoPvsEntitySubComponent c) = ArtDecoPvsEntitySubComponent (map f c)
 
 
 derive instance Generic (ArtDecoCenterContent a) _
 derive instance Generic (ArtDecoCenterContent a) _
 derive instance Eq a => Eq(ArtDecoCenterContent a)
 derive instance Eq a => Eq(ArtDecoCenterContent a)
 instance Show a => Show(ArtDecoCenterContent a) where
 instance Show a => Show(ArtDecoCenterContent a) where
   show = genericShow
   show = genericShow
+instance Functor ArtDecoCenterContent where
+  map f (ArtDecoCenterContent nel) = ArtDecoCenterContent (map (map f) nel)
 
 
 derive instance Generic (ArtDecoCenterHeader a) _
 derive instance Generic (ArtDecoCenterHeader a) _
 derive instance Eq a => Eq(ArtDecoCenterHeader a)
 derive instance Eq a => Eq(ArtDecoCenterHeader a)
 instance Show a => Show(ArtDecoCenterHeader a) where
 instance Show a => Show(ArtDecoCenterHeader a) where
   show = genericShow
   show = genericShow
+instance Functor ArtDecoCenterHeader where
+  map f (ArtDecoCenterHeader {bold, normal, light}) =
+    ArtDecoCenterHeader ({
+      bold: f bold,
+      normal: map f normal,
+      light: map (map f) light
+    })
 
 
 derive instance Generic (ArtDecoCenter a) _
 derive instance Generic (ArtDecoCenter a) _
 derive instance Eq a => Eq(ArtDecoCenter a)
 derive instance Eq a => Eq(ArtDecoCenter a)
 instance Show a => Show(ArtDecoCenter a) where
 instance Show a => Show(ArtDecoCenter a) where
   show = genericShow
   show = genericShow
+instance Functor ArtDecoCenter where
+  map f (ArtDecoCenter {content, header}) =
+    ArtDecoCenter ({content: map f content, header: map f header})
 
 
 derive instance Generic (ArtDecoPvsEntity a) _
 derive instance Generic (ArtDecoPvsEntity a) _
 derive instance Eq a => Eq(ArtDecoPvsEntity a)
 derive instance Eq a => Eq(ArtDecoPvsEntity a)
 instance Show a => Show(ArtDecoPvsEntity a) where
 instance Show a => Show(ArtDecoPvsEntity a) where
   show = genericShow
   show = genericShow
+instance Functor ArtDecoPvsEntity where
+  map f (ArtDecoPvsEntity {side, center}) =
+    ArtDecoPvsEntity ({side, center: map f center})
 
 
 
 
 parseArtDecoPvsEntitySubComponent ∷ Parser (ArtDecoPvsEntitySubComponent DetachedNode)
 parseArtDecoPvsEntitySubComponent ∷ Parser (ArtDecoPvsEntitySubComponent DetachedNode)

+ 3 - 0
src/LinkedIn/ArtDecoCard.purs

@@ -25,6 +25,9 @@ derive instance Generic (ArtDecoCardElement a) _
 derive instance Eq a => Eq (ArtDecoCardElement a)
 derive instance Eq a => Eq (ArtDecoCardElement a)
 instance Show a => Show (ArtDecoCardElement a) where
 instance Show a => Show (ArtDecoCardElement a) where
   show = genericShow
   show = genericShow
+instance Functor ArtDecoCardElement where
+  map f (ArtDecoCardElement {pvs_entity}) =
+    ArtDecoCardElement ({pvs_entity: map f pvs_entity})
 
 
 parseArtDecoCard :: Parser (ArtDecoCardElement DetachedNode)
 parseArtDecoCard :: Parser (ArtDecoCardElement DetachedNode)
 parseArtDecoCard n = do
 parseArtDecoCard n = do

+ 3 - 0
src/LinkedIn/ArtDecoTab.purs

@@ -25,6 +25,9 @@ derive instance Generic (ArtDecoTabElement a) _
 derive instance Eq a => Eq (ArtDecoTabElement a)
 derive instance Eq a => Eq (ArtDecoTabElement a)
 instance Show a => Show (ArtDecoTabElement a) where
 instance Show a => Show (ArtDecoTabElement a) where
   show = genericShow
   show = genericShow
+instance Functor ArtDecoTabElement where
+  map f (ArtDecoTabElement {pvs_entity}) =
+    ArtDecoTabElement ({pvs_entity: map f pvs_entity})
 
 
 parseArtDecoTab :: Parser (ArtDecoTabElement DetachedNode)
 parseArtDecoTab :: Parser (ArtDecoTabElement DetachedNode)
 parseArtDecoTab n = do
 parseArtDecoTab n = do