nwolverson/atom-ide-purescript

Autocomplete: dotting into records

Bellarmine-Head opened this issue · 1 comments

type Person =
  {
    age  :: Int,
    name :: String
  }

testPerson :: Person
testPerson = { age: 56, name: "Andrew" }

Q1: with the above definitions, typing testPerson (say within a function in the same module) and then a . does not bring up a list of the record's fields, age and name. Should it do so? Tooltips certainly reveal that the editor knows the type of testPerson; sometimes it's revealed as Person and at other times as an anonymous record type with fields age of int and name of string, but in neither case does dotting-into testPerson show its fields in auto-complete.

Q2: related, but different... with the above definitions and this function:-

showPerson :: Person -> String
showPerson p = p.name <> " (" <> (show p.age) <> ")"

typing p within the function body brings up an autocomplete list without this local, and dotting into p also doesn't show the record's fields. Are these behaviours to be expected?

Is it worth opening an issue for these matters?

(I have the latest purescript, pulp, Atom.io, psc atom packages, etc.)

No, neither of these things is going to happen at present, though I agree they are desirable, because type information is provided by psc-ide (see the compiler repository) which currently operates on the basis of externs files rather than a full (typed) AST, making it fast but restricting to information on top-level identifiers. (Moreover, only exported identifiers, except in the case that you first rebuild (by saving) the individual file in question)

@kritzcreek was investigating completion for records but the current solution isn't ideal & may not progress.

So discussion of these particular issues should be in the purescript repo (probably there will be some existing issue tagged with psc-ide) - but I don't object in general to issues being raised here where it's not clear to you :)