purescript / purescript/trypurescript

Type search "/search" endpoint not working

Đang mở
#269 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
PureScript
Star
121
Fork
51
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The /search endpoint doesn't seem to work (it's not officially documented, so I'm not sure if it's expected to work)

❯ curl -G --data-urlencode 'q=Unit' https://compile.purescript.org/search
{"error":"Cannot parse type"}% 

I am able to get it "working" locally (maybe not as intended) by stripping the TokLayoutStart and TokLayoutEnd tokens

tryParseType :: Text -> Maybe P.SourceType
tryParseType = hush . fmap (CST.convertType "<file>") . runParser CST.parseTypeP
  where
    hush = either (const Nothing) Just

    runParser :: CST.Parser a -> Text -> Either String a
    runParser p =
      let p' = do
            _ <- CSTM.token CST.TokLayoutStart
            result <- p
            _ <- CSTM.token CST.TokLayoutEnd
            _ <- CSTM.token CST.TokEof
            pure result
      in bimap (CST.prettyPrintError . NE.head) snd
        . CST.runTokenParser p'
        . CST.lexTopLevel

This produces output for certain input

❯ curl -G --data-urlencode 'q=Unit' localhost:8081/search | jq '.'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   784    0   784    0     0    341      0 --:--:--  0:00:02 --:--:--   342
{
  "results": [
    "Control.Subcategory.Closed.assertClosed",
    "Control.Subcategory.HasStart.start",
    "Control.Subcategory.HasUnit.unit",
    "Data.Bounded.bottom",
    "Data.Bounded.top",
    "Data.Bounded.Generic.genericBottom",
    "Data.Bounded.Generic.genericTop",
    "Data.HeytingAlgebra.ff",
    "Data.HeytingAlgebra.tt",
    "Data.HeytingAlgebra.Generic.genericFF",
    "Data.HeytingAlgebra.Generic.genericTT",
    "Data.Monoid.mempty",
    "Data.Monoid.Generic.genericMempty",
    "Data.Ring.Module.mzeroL",
    "Data.Ring.Module.mzeroR",
    "Data.Semiring.one",
    "Data.Semiring.zero",
    "Data.Semiring.Generic.genericOne",
    "Data.Semiring.Generic.genericZero",
    "Data.Typelevel.Undefined.undefined",
    "Data.Unit.unit",
    "Formless.Class.Initial.initial",
    "Options.Applicative.Builder.idm",
    "Partial.crash",
    "Protobuf.Internal.Common.default",
    "Undefined.undefined"
  ]
}

but crashes on List a -> Maybe a (one of @paf31's examples from #55)

❯ curl -G --data-urlencode 'q=List a -> Maybe a' localhost:8081/search
curl: (52) Empty reply from server

q=(a -> f b) -> t a -> f (t b) fails similarly, and in both cases in the server logs I see

An internal error occurred during compilation: Skolem has no kind
Please report this at https://github.com/purescript/purescript/issues
CallStack (from HasCallStack):
  error, called at src/Language/PureScript/Crash.hs:23:3 in purescript-cst-0.4.0.0-BFtByvwp6rF98omNSi831H:Language.PureScript.Crash
  internalError, called at src/Language/PureScript/TypeChecker/Kinds.hs:501:32 in purescript-0.14.5-4MEYSDbbzAH8atq8Yve4k8:Language.PureScript.TypeChecker.Kinds
  elaborateKind, called at src/Language/PureScript/TypeChecker/Unify.hs:70:9 in purescript-0.14.5-4MEYSDbbzAH8atq8Yve4k8:Language.PureScript.TypeChecker.Unify

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Start at the /search endpoint and its tryParseType parser path, reproducing the documented curl queries locally. Trace failures through Language.PureScript.TypeChecker.Kinds at line 501 and Language.PureScript.TypeChecker.Unify at line 70. Done means valid type searches return results or a handled error without the endpoint rejecting basic input or crashing.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Lĩnh vực
api, backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.