Skill.purs 763 B

12345678910111213141516171819202122232425262728293031
  1. module LinkedIn.Profile.Skill where
  2. import Prelude
  3. import Data.Either (Either, note)
  4. import Data.Generic.Rep (class Generic)
  5. import Data.Maybe (Maybe(..))
  6. import Data.Show.Generic (genericShow)
  7. import LinkedIn.ArtDecoTab (ArtDecoTabElement, toHeaderBold)
  8. import LinkedIn.UIElements.Types (UIElement(..), UIString(..))
  9. data Skill = Skill {
  10. name :: String
  11. }
  12. derive instance Generic Skill _
  13. instance Show Skill where
  14. show = genericShow
  15. fromUI ∷ ArtDecoTabElement UIElement → Either String Skill
  16. fromUI tab = ado
  17. name <- note "No position found" $ extractName bold
  18. in
  19. Skill { name }
  20. where
  21. bold = toHeaderBold tab
  22. extractName :: UIElement -> Maybe String
  23. extractName = case _ of
  24. UIElement (UIStringPlain str) -> Just str
  25. _ -> Nothing