Utils.purs 834 B

123456789101112131415161718192021222324
  1. module Test.Utils where
  2. import Prelude
  3. import Data.Date (Month)
  4. import Data.Either (Either(..))
  5. import Data.Int (toNumber)
  6. import Data.Maybe (fromJust)
  7. import Data.Traversable (class Traversable, traverse)
  8. import LinkedIn.DetachedNode (DetachedNode)
  9. import LinkedIn.UI.Basic.Parser (toYear)
  10. import LinkedIn.UI.Basic.Types (MonthYear(..))
  11. import LinkedIn.UI.Elements.Parser (toUIElement)
  12. import LinkedIn.UI.Elements.Types (UIElement)
  13. import Partial.Unsafe (unsafePartial)
  14. toMonthYear' :: Month -> Int -> MonthYear
  15. toMonthYear' m y = MonthYear m y' where
  16. y' = unsafePartial $ fromJust $ toYear $ toNumber y
  17. fromDetachedToUI ∷ ∀ t. Traversable t ⇒ t DetachedNode → Either String (t UIElement)
  18. fromDetachedToUI el = case traverse toUIElement el of
  19. Left _ -> Left "error on conversion to UI element"
  20. Right ui -> Right ui