Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

feat: rubiks cube sample #3

Merged
merged 16 commits into from
Aug 8, 2022
Merged

Conversation

EdAyers
Copy link
Member

@EdAyers EdAyers commented Jun 24, 2022

This PR includes a minimal example of user widgets and a more involved rubiks cube example

Tasks

@EdAyers EdAyers mentioned this pull request Jun 24, 2022
8 tasks
@lovettchris lovettchris self-requested a review June 28, 2022 03:56
open System Lake DSL

def jsTarget (pkgDir : FilePath) : FileTarget :=
let jsFile := pkgDir / "widget/dist/rubiks.js"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work on windows, perhaps this would be better:

  let jsFile := pkgDir / "widget" / "dist" / "rubiks.js"
  let srcFiles := inputFileTarget <| pkgDir / "widget" / "src" / "rubiks.tsx"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the proposed change is good, but we also need this fix in lean for it to work: leanprover/lean4#1257

WidgetsMinimal/WidgetsMinimal.lean Outdated Show resolved Hide resolved
@Vtec234
Copy link
Contributor

Vtec234 commented Aug 2, 2022

@lovettchris this should be ready for review and testing.

@lovettchris
Copy link
Contributor

@lovettchris this should be ready for review and testing.

LEAN_PATH=.\build\lib c:\Users\clovett.elan\toolchains\leanprover--lean4---nightly-2022-08-01\bin\lean.exe ...\Rubiks.lean -R ... -o .\build\lib\Rubiks.olean -i .\build\lib\Rubiks.ilean -c .\build\ir\Rubiks.c
error: stdout:
...\Rubiks.lean:16:15: error: no such file or directory (error code: 2)
file: ..../widget/dist/rubiks.js
...\Rubiks.lean:13:2: error: cannot evaluate code because 'sorryAx' uses 'sorry' and/or contains errors
error: external command c:\Users\clovett.elan\toolchains\leanprover--lean4---nightly-2022-08-01\bin\lean.exe exited with status 1
error: build failed

@Vtec234
Copy link
Contributor

Vtec234 commented Aug 2, 2022

@lovettchris unfortunately we are blocked on leanprover/lean4#2762 and this error will likely come up again. However please see the updated README.md - the new instructions are to run lake build rubiksJs first.

@lovettchris
Copy link
Contributor

lovettchris commented Aug 2, 2022

@lovettchris unfortunately we are blocked on leanprover/lean4#2762 and this error will likely come up again. However please see the updated README.md - the new instructions are to run lake build rubiksJs first.

lake build rubiksJs
> npm install    # in directory .\widget
error: no such file or directory (error code: 2)
error: build failed

I think the problem is that you are hard coding forward slashes in a string literal which results in an invalid path on Windows. Can you change include_str to take a System.FilePath so i can write this instead:

javascript:= include_str (System.FilePath.mk "." / "widget" / "dist" / "rubiks.js")

which generates the correct backslash path on Windows? We then seems to have one more bug in System.FilePath where it is generating a leading 'slash' in the combined path \d%3A\Temp\lean4-samples\RubiksCube\./widget/dist/rubiks.js - and that is also invalid on Windows. The string should be d:\Temp\lean4-samples\RubiksCube\.\widget\dist\rubiks.js... this seems to be a bug in Lean.Core.Context where ctx.fileName is returning the mangled path.

@Vtec234
Copy link
Contributor

Vtec234 commented Aug 2, 2022

It looks like it's failing in the npm install step, long before the include_str has any relevance. We could definitely be more correct about paths, but fwiw forward-slash paths have always worked for me on modern versions of Windows. This looks a bit like leanprover/lean4#1257.

@lovettchris
Copy link
Contributor

Could be related to that open issue, but it's definitely failing in the include_str, I see this in the editor:

image

I also filed this new bug against lean as a reminder to complete that open PR:
leanprover/lean4#1410

@lovettchris
Copy link
Contributor

Seems to work great on Linux though:

image

@lovettchris
Copy link
Contributor

lovettchris commented Aug 2, 2022

I also verified that leanprover/lean4#1257 fixes the NPM build problem, but not the path problem, so I still see this in the editor (on Windows) after lake build rubiksJs has succeeded.

image

@lovettchris
Copy link
Contributor

@EdAyers can you add a link and small blurb about the sample in the top level https://github.com/EdAyers/lean4-samples/blob/rubiks/README.md ?

@EdAyers EdAyers marked this pull request as ready for review August 3, 2022 09:38
EdAyers added a commit to EdAyers/lean4 that referenced this pull request Aug 3, 2022
depends on leanprover-community/lean4-samples#3

- fix some errors spotted by @utensil
- remove some todos
- update link to sample
EdAyers referenced this pull request in leanprover/lean4 Aug 3, 2022
@EdAyers
Copy link
Member Author

EdAyers commented Aug 3, 2022

@leodemoura could the include_str macro live in core?

@leodemoura
Copy link
Contributor

@leodemoura could the include_str macro live in core?

Yes!

@EdAyers
Copy link
Member Author

EdAyers commented Aug 4, 2022

Added here: leanprover/lean4@98513fa

@lovettchris lovettchris merged commit e6be551 into leanprover-community:main Aug 8, 2022
@EdAyers EdAyers deleted the rubiks branch August 9, 2022 09:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants