Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

celsius example doesn't work when simplified #622

Open
yegor256 opened this issue Dec 11, 2024 · 2 comments
Open

celsius example doesn't work when simplified #622

yegor256 opened this issue Dec 11, 2024 · 2 comments

Comments

@yegor256
Copy link
Member

yegor256 commented Dec 11, 2024

I'm doing it like this:

{⟦
  c ↦ ξ.number(as-bytes ↦ ⟦ Δ ⤍ 40-39-00-00-00-00-00-00 ⟧),
  φ ↦ ξ.c.times(x ↦ ⟦ Δ ⤍ 3F-FC-CC-CC-CC-CC-CC-CD ⟧).plus(x ↦ ⟦ Δ ⤍ 40-40-00-00-00-00-00-00 ⟧),
  number ↦ ⟦
    as-bytes ↦ ∅,
    times ↦ ⟦ x ↦ ∅, λ ⤍ Lorg_eolang_number_times ⟧,
    plus ↦ ⟦ x ↦ ∅, λ ⤍ Lorg_eolang_number_plus ⟧,
  ⟧
⟧}

This is very similar to what you have in the dataization.yaml test case, but I'm not importing the entire number.phi and don't use bytes.phi. I believe, my example should work.

I'm running it like this:

$ eo-phi-normalizer dataize --recursive --chain celsius.phi

It's not getting to a single data, but prints:

unknown atom (Lorg_eolang_number_times): ...

What it's unknown? It's exactly the same atom as in number.phi.

@yegor256
Copy link
Member Author

@deemp please, check this one

@fizruk
Copy link
Collaborator

fizruk commented Dec 12, 2024

The following is missing from your example:

  1. φ ↦ ξ.as-bytes in the definition of number. This is important for the atoms (plus and times) to be able to dataize their arguments.
  2. Since atoms wrap their results in Φ.org.eolang.number(as-bytes ↦ Φ.org.eolang.bytes(Δ ⤍ ...)), it is important that those are defined, so Φ.org.eolang.number and Φ.org.eolang.bytes need to be defined.
  3. When using dataize, you need to add --as-package or add λ ⤍ Package explicitly to the global object.

Also, using φ in a global object may lead to infinite dataization. This is because atoms produce Φ.org.eolang.something and then when the global object does not have org dataization tries to go into φ, resulting in a loop.

Below is a minimal working example:

cat celsius.phi
{⟦
  c ↦ ξ.org.eolang.number(as-bytes ↦ ⟦ Δ ⤍ 40-39-00-00-00-00-00-00 ⟧),
  result ↦ ξ.c.times(x ↦ ⟦ Δ ⤍ 3F-FC-CC-CC-CC-CC-CC-CD ⟧).plus(x ↦ ⟦ Δ ⤍ 40-40-00-00-00-00-00-00 ⟧),
  org ↦ ⟦
    eolang ↦ ⟦
      number ↦ ⟦
        as-bytes ↦ ∅,
        φ ↦ ξ.as-bytes,
        times ↦ ⟦ x ↦ ∅, λ ⤍ Lorg_eolang_number_times ⟧,
        plus ↦ ⟦ x ↦ ∅, λ ⤍ Lorg_eolang_number_plus ⟧,
      ⟧,
      bytes ↦ ⟦
        Δ ⤍ ∅
      ⟧,
    ⟧,
  ⟧
⟧}
eo-phi-normalizer dataize --as-package celsius.phi
{
  ⟦
    c ↦ ⟦
      Δ ⤍ 40-39-00-00-00-00-00-00
    ⟧,
    result ↦ 77.0,
    org ↦ ⟦
      eolang ↦ ⟦
        number ↦ ⟦
          as-bytes ↦ ∅,
          φ ↦ ξ.as-bytes,
          times ↦ ⟦
            x ↦ ∅,
            λ ⤍ Lorg_eolang_number_times
          ⟧,
          plus ↦ ⟦
            x ↦ ∅,
            λ ⤍ Lorg_eolang_number_plus
          ⟧
        ⟧,
        bytes ↦ ⟦
          Δ ⤍ ∅
        ⟧
      ⟧
    ⟧
  ⟧
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants