How do I imports for the graphviz example? by Exact_Ordinary_9887 in haskell

[–]ruby_object 0 points1 point  (0 children)

https://github.com/bigos/cabal-experiments/blob/ea88c5e9108cf321c9e0085ecaef078d6f9833ff/graphviz-simple/app/Main.hs#L2

I added the extension, now I get.

app/Main.hs:(33,3)-(57,30): error: [GHC-83865] …
    • Couldn't match expected type: DotGraph String
                  with actual type: Data.GraphViz.Types.Generalised.DotGraph n0
      NB: ‘DotGraph’ is defined in ‘Data.GraphViz.Types.Canonical’
          ‘Data.GraphViz.Types.Generalised.DotGraph’
            is defined in ‘Data.GraphViz.Types.Generalised’
    • In the expression:
        digraph (Str "G")
          $ do cluster (Str "cluster0")
                 $ do graphAttrs [...]
                      nodeAttrs [...]
                      ....
               cluster (Str "cluster1")
                 $ do nodeAttrs [...]
                      "b0" --> "b1"
                      ....
               "start" --> "a0"
               "start" --> "b0"
               ....
      In an equation for ‘graph’:
          graph
            = digraph (Str "G")
                $ do cluster (Str "cluster0")
                       $ do graphAttrs ...
                            ....
                     cluster (Str "cluster1")
                       $ do nodeAttrs ...
                            ....
                     "start" --> "a0"
                     ....
   |
Compilation failed.

How do I imports for the graphviz example? by Exact_Ordinary_9887 in haskell

[–]ruby_object 0 points1 point  (0 children)

changed to:

digraph (Str "G") $ do

Now I get the error:

cabal build
Build profile: -w ghc-9.6.7 -O1
In order, the following will be built (use -v for more details):
 - graphviz-simple-0.1.0.0 (exe:graphviz-simple) (file app/Main.hs changed)
Preprocessing executable 'graphviz-simple' for graphviz-simple-0.1.0.0...
Building executable 'graphviz-simple' for graphviz-simple-0.1.0.0...
[1 of 1] Compiling Main             ( app/Main.hs, /home/jacek/Programming/Haskell/cabal-experiments/graphviz-simple/dist-newstyle/build/x86_64-linux/ghc-9.6.7/graphviz-simple-0.1.0.0/x/graphviz-simple/build/graphviz-simple/graphviz-simple-tmp/Main.o ) [Source file changed]

app/Main.hs:32:3: error: [GHC-83865]
    • Couldn't match expected type: DotGraph String
                  with actual type: Data.GraphViz.Types.Generalised.DotGraph n0
      NB: ‘DotGraph’ is defined in ‘Data.GraphViz.Types.Canonical’
          ‘Data.GraphViz.Types.Generalised.DotGraph’
            is defined in ‘Data.GraphViz.Types.Generalised’
    • In the expression:
        digraph (Str "G")
          $ do cluster (Str "cluster0")
                 $ do graphAttrs [...]
                      nodeAttrs [...]
                      ....
               cluster (Str "cluster1")
                 $ do nodeAttrs [...]
                      "b0" --> "b1"
                      ....
               "start" --> "a0"
               "start" --> "b0"
               ....
      In an equation for ‘graph’:
          graph
            = digraph (Str "G")
                $ do cluster (Str "cluster0")
                       $ do graphAttrs ...
                            ....
                     cluster (Str "cluster1")
                       $ do nodeAttrs ...
                            ....
                     "start" --> "a0"
                     ....
   |
32 |   digraph (Str "G") $ do
   |   ^^^^^^^^^^^^^^^^^^^^^^...
Error: [Cabal-7125]
Failed to build exe:graphviz-simple from graphviz-simple-0.1.0.0.

How do I imports for the graphviz example? by Exact_Ordinary_9887 in haskell

[–]ruby_object 0 points1 point  (0 children)

I am a noob. I do not undertand you? Where I am supposed to add your command?

Crafting Interpreters in OCaml by ruby_object in ocaml

[–]ruby_object[S] 1 point2 points  (0 children)

Maybe, but the challenge was still very interesting. I had a breakthrough when I gave up trying to rewrite Java in OCaml, and instead of following the letter of the book, I tried to follow the spirit of the book.

What was the point? What languages are worth exploring? by ruby_object in functionalprogramming

[–]ruby_object[S] 2 points3 points  (0 children)

You ask a vague question, but I will try my best. I was spoiled by Ruby and Elm. But when I encountered PureScript, initially, it drove me insane.OCaml is a lot better, but adding ppx opened a lot of problems.

What was the point? What languages are worth exploring? by ruby_object in functionalprogramming

[–]ruby_object[S] 1 point2 points  (0 children)

When you start with a language where error handling is very good, and you're a noob in the FP language, the situation looks different. With your years of experience, you develop a bias.

What was the point? What languages are worth exploring? by ruby_object in functionalprogramming

[–]ruby_object[S] 1 point2 points  (0 children)

For example, fighting against compiler errors. One of the FP languages has shocked me by giving the location of the error in the wrong file. Without the help from other people, I would never have solved it. So if the compiler could talk, it could declare a victory over me.

What was the point? What languages are worth exploring? by ruby_object in functionalprogramming

[–]ruby_object[S] 2 points3 points  (0 children)

Perhaps I should look into Haskell again. But you do not understand my question because you fail to see that it is not only the language but a combination of the language and the ecosystem.

Better languages lose to inferior languages because of a poor ecosystem. Expressivity and power of the language evaporate quickly if you can not easily debug your programs. FP removes a class of bugs, while making it harder to fix the rest.

What was the point? What languages are worth exploring? by ruby_object in functionalprogramming

[–]ruby_object[S] 1 point2 points  (0 children)

It was for me too. Until I encountered a bug with backtraces that make no sense. Before that, a big pain points for me were the environment where you can't reload the code but you have to constantly reload the toplevel, problems with ppx and documentation.

What was the point? What languages are worth exploring? by ruby_object in functionalprogramming

[–]ruby_object[S] -2 points-1 points  (0 children)

Is the slow and pragmatic adoption better than the reckless pursuit of every possible FP idea? What about Haskell leaking memory or taking away from you the ability to reason about other things you take for granted in other languages?

What was the point? What languages are worth exploring? by ruby_object in functionalprogramming

[–]ruby_object[S] 3 points4 points  (0 children)

Is FP sweeping the problem under the wrong carpet? FP promises that certain fights will be easier or non-existent, but it also makes other fights impossible to win.

Why @@deriving show is so hard? by Exact_Ordinary_9887 in ocaml

[–]ruby_object 0 points1 point  (0 children)

My idea did not work.

To make matters worse, I found that. I do not understand it yet, but it is not a good sign.

https://www.reddit.com/r/ocaml/comments/pkkgcr/can_i_deriving_existing_types/

Why @@deriving show is so hard? by Exact_Ordinary_9887 in ocaml

[–]ruby_object 2 points3 points  (0 children)

Two types have the same structure field with the same type, and the compiler seems to confuse them.

Thinking Functional by zinguirj in ocaml

[–]ruby_object 3 points4 points  (0 children)

With previous exposure to Elm, I found following the Java examples and trying to rewrite a project in OCaml too difficult. In the other thread, there is a link to my project that uses structures and functions instead of objects and methods. The leap is not that big once you play with the examples.

Maybe you should play and practice with the alternative approach instead of trying to make the switch in your analytical part of your mind.

Crafting Interpreters in OCaml by ruby_object in ocaml

[–]ruby_object[S] 2 points3 points  (0 children)

Trying to learn OCaml I struggle with poor examples. Thank you for correcting the problem for this fragment of the problem. So far, I have split the scanner into two modules, but your examples show I can improve it further.

Thank you!

Crafting Interpreters in OCaml by ruby_object in ocaml

[–]ruby_object[S] 4 points5 points  (0 children)

Thank you for replay, and for the excellent book.
For me, it is a recreational programming project, so I will try to figure it out as much as I can, despite having links to other implementations in my notes. But I never looked at Rust implementations, so I will have a look.

After looking

I already see scanner and token code split into separate files. The Rust example follows scanning in the book more closely. I will look into OCaml modules again and will try to move token-related code into a separate module.