Hi
I am working with the following block of code:
assembleMRSSWidget ∷ WidgetAssembler MRSSWidget
assembleMRSSWidget wid = do
MediaRSS { media } ← useMediaRSS (MediaRSSKey "ccef7c")
-- MediaRSS { media } ← useMediaRSS rssKey
-- 1. Test case: This outputs a string
test ← case Array.index media 0 of
Nothing → do
pure ""
Just (MediaRSSItem { url }) → do
useURL url
outputWidget' \aabb → mkEffectFn4 \doc parent tsl onE → do
img ← imgEle aabb "" doc parent
stopAt ← onFrameDuring (TimeSlice.actual tsl)
{ during: mkEffectFn2 \t' s@(Tuple i t) →
if diffInst t' t >= Milliseconds 10000.0 then do
let i' = (i + 1) `mod` Array.length media
MediaRSSItem item = fromMaybe (MediaRSSItem { url: "", duration: (Seconds 0.0), md5Checksum: "", fileSizeInBytes: 0.0, daysOld: (Days 0.0), fileType: ImageMediaFile })
(Array.index media i)
-- 2. This is accepted as a valid string
HTMLImageElement.setSrc (test) img
-- 3. This is not accepted as a valid string
HTMLImageElement.setSrc (useURL item.url) img
pure (Tuple i' t')
else
pure s
, end: mkEffectFn2 \_ _ → pure unit
}
(Tuple (1 `mod` Array.length media) bottom)
pure stopAt
I labeled the comments of the trouble spots in this code.
- This is some test code that I wrote prior and it outputs a normal String
- If I try to pass it into setSrc it accepts because it is a normal string
- If I try to run useURL anywhere within outputWidget’ it instead errors saying:
Could not match type
ValidatorT String (Tuple (CatList String) (Map AssemblerSource String))
{ contentKeyURLMap :: Map ContentKey
{ cacheKey :: String
, cached :: Boolean
, etag :: String
, request :: ...
, url :: String
}
, dataGridSourceMap :: Map DataGridKey
{ etag :: String
, value :: DataGridSource
}
, mediaRSSMap :: Map MediaRSSKey
{ etag :: String
, value :: MediaRSS
}
, textRSSDataMap :: Map TextRSSKey
{ etag :: String
, value :: TextRSSData
}
, timeZoneConverter :: { etag :: String
, value :: { fromUTC :: ...
, incMaxYear :: Year
, incMinYear :: Year
, timeZone :: TimeZone
, toUTC :: ...
}
}
, urlMap :: Map String
{ cacheKey :: String
, cached :: Boolean
, etag :: String
, request :: ...
, url :: String
}
, videoOverlappable :: Boolean
, volume :: { etag :: String
, value :: Percent Number
}
, weatherLayoutDataMap :: Map LocationId
{ etag :: String
, value :: WeatherLayoutData
}
}
Identity
String
with type
String
while checking that type ValidatorT String (Tuple (CatList String) (Map AssemblerSource String))
{ contentKeyURLMap :: Map ContentKey
{ cacheKey :: String
, cached :: Boolean
, etag :: String
, request :: ...
, url :: String
}
, dataGridSourceMap :: Map DataGridKey
{ etag :: String
, value :: DataGridSource
}
, mediaRSSMap :: Map MediaRSSKey
{ etag :: String
, value :: MediaRSS
}
, textRSSDataMap :: Map TextRSSKey
{ etag :: String
, value :: TextRSSData
}
, timeZoneConverter :: { etag :: String
, value :: { fromUTC :: ...
, incMaxYear :: Year
, incMinYear :: Year
, timeZone :: TimeZone
, toUTC :: ...
}
}
, urlMap :: Map String
{ cacheKey :: String
, cached :: Boolean
, etag :: String
, request :: ...
, url :: String
}
, videoOverlappable :: Boolean
, volume :: { etag :: String
, value :: Percent Number
}
, weatherLayoutDataMap :: Map LocationId
{ etag :: String
, value :: WeatherLayoutData
}
}
Identity
String
is at least as general as type String
while checking that expression useURL (item.url)
has type String
in value declaration assembleMRSSWidget
PureScript(TypesDoNotUnify)
I dont understand why it is outputting a different type within the outputWidget block. Any help would be appreciated.
Thanks