Closed
Description
Description
Some code fails to compile with an un-annotated function in a let
block; however, the same code will compile if the un-annotated function is moved outside of the let block.
To Reproduce
map3 :: forall a b c d. (a -> b -> c -> d) -> Array a -> Array b -> Array c -> Array d
map3 fn a b c =
let
-- Annotation is required if toZip is defined in let block
--toZip :: forall x. Array x -> ZipList x
toZip = ZipList <<< LazyList.fromFoldable
la = toZip a
lb = toZip b
lc = toZip c
in
Array.fromFoldable $ lift3 fn la lb lc
-- It's fine to define without annotation globally
--toZip = ZipList <<< LazyList.fromFoldable
https://try.ps.ai/?gist=87e51987560be0007e7291699afcacd4
There is no compilation issue with an un-annotated toZip
within a let
block if it can be monomorphic throughout the let
block. Thanks to @3ddyy for discovering this.
-- Annotation not required for ?monomorphic? toZip
map3mono :: forall a. (a -> a -> a -> a) -> Array a -> Array a -> Array a -> Array a
map3mono fn a b c =
let
toZip = ZipList <<< LazyList.fromFoldable
la = toZip a
lb = toZip b
lc = toZip c
in
Array.fromFoldable $ lift3 fn la lb lc
Expected behavior
I expect the version with an un-annotated toZip
in the let
block to compile.
PureScript version
0.13.8