ocsigen / ocsigen/tyxml

Typing & composability issue

Open
#175 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement typing
Dominant language
OCaml
Stars
179
Forks
63
Avg merge
5h
Merged PRs (30d)
22

Description

open Tyxml

let page title content = [%html {|                                                  
  <html>                                                                            
    <head>                                                                          
     <title>|} title {|</title>                                                     
     <link rel=stylesheet href="/style.css" />                                      
    </head>                                                                         
    <body>|} content {|</body>                                                      
    </html>                                                                         
 |}]

let a_or_button contents =
  if true then
    Html.a contents
  else
    Html.button contents

let _ = page [%html "foo"] [Html.a []]
let _ = page [%html "foo"] [Html.button []]
let _ = page [%html "foo"] [a_or_button []]

Surprisingly, the last line fails to typecheck, with the following error: https://paste.isomorphis.me/Tgo

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the OCaml reproduction in the issue, especially the a_or_button definition and the final page call, then inspect the linked type-checking error. Determine why the composed anchor-or-button value is rejected while each direct value succeeds. Done means the final example typechecks without regressing the two preceding examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.