Hi,
I am currently using neovim with coc.nvim to get coding assist via PureScript language server.
I often wish, type hints would be a bit more verbose and dynamic. Just an example from PureScript Ebook chapter 11 (type definitions at bottom for quick glance):
cheat :: Game Unit
cheat = do
GameState state <- get
tell
$ foldl (\acc x -> ("You now have the " <> show x) : acc) L.Nil
$ S.unions state.items
let newInventory = foldl S.union state.inventory state.items
put $ GameState state { items = M.empty, inventory = newInventory }
1. If hovering for example over tell
, foldl
, S.unions
and pressing K
, I only get type hints for the generic type constructors
foldl :: ∀ (f ∷ Type -> Type) (a ∷ Type) (b ∷ Type).
Foldable f ⇒ (b → a → b) → b → f a → b
Is it possible to hint something like
-
f a
=Set GameItem
-
b
=List String
inside foldl
, i.e. where type parameters have been instantiated?
2. Some symbols don’t show anything at all, like when inspecting acc
, state.items
or state.inventory
, giving hint a status hint at bottom:
[coc.nvim] hover not found
Can these type hints be improved? This really would make the barrier lower for newcomers like me.
Also expressive type hints (and concise error messages) are those features, I am missing most from TypeScript language.
Thanks.
Type defintions
import Data.List as L
import Data.Map as M
import Data.Set as S
data GameItem = Candle | Matches
newtype GameEnvironment = GameEnvironment
{ playerName :: PlayerName
, debugMode :: Boolean
}
type Log = L.List String
type Game = RWS GameEnvironment Log GameState
newtype GameState = GameState
{ items :: M.Map Coords (S.Set GameItem)
, player :: Coords
, inventory :: S.Set GameItem
}