GHCJS で動作するように、いくつかの JS ライブラリ用に JS FFI を構築しようとしています。リストを単一の JSVal に変換する必要があります。
listToJSVal :: PToJSVal a => [a] -> JSVal
listToJSVal = map pToJSVal
しかし、エラーが発生します
Couldn't match type ‘[JSVal]’ with ‘JSVal’
Expected type: [a] -> JSVal
Actual type: [a] -> [JSVal]
明らかに、concat関数が必要ですが、使用mconcat
すると
Could not deduce (Monoid JSVal) arising from a use of ‘mconcat’
from the context (PToJSVal a)
bound by the type signature for
たぶん、この変換を適切に行う簡単な方法はありますか?