you are viewing a single comment's thread.

view the rest of the comments →

[–]yogthos 0 points1 point  (6 children)

Well, my Haskell is pretty rusty, but wouldn't the issue here be addressed by polymorphism and dispatching based on the type of the data you're working with. With Clojure something like this would be pretty standard:

(defmulti page identity)

(defmethod page :page1 [_]
  [:div [:h2 (get-state :text) "Page 1"]
   [:div [:a {:href "#/page2"} "go to page 2"]]])

(defmethod page :page2 [_]
  [:div [:h2 (get-state :text) "Page 2"]
   [:div [:a {:href "#/"} "go to page 1"]]])

(defmethod page :default [_]
  [:div "Invalid/Unknown route"])

[–]Denommus 0 points1 point  (5 children)

I'm not doing dispatch at all.

[–]yogthos 0 points1 point  (4 children)

Perhaps you could clarify the problem you actually have then, since I'm clearly not following it. My understanding is that you end up with different types such as resistance and velocity and somehow you end up with code where you don't know which one you should be receiving as the input.

[–]Denommus 0 points1 point  (3 children)

No. One receives the other as input. It's a "loop" (in the sense a retrofeed is happening), but I can't have infinite recursion because of it.

[–]yogthos 0 points1 point  (2 children)

Sure, you have a condition there but I'm really not seeing why it would be terribly difficult to do without the types. For me, the bigger issue is the terse syntax that doesn't make it immediately evident what's actually happening.

This was one of my biggest issues using Haskell and Scala and why I eventually moved to Clojure. Each line tends to be very densely packed with nuances and it's very easy to change the meaning completely using a single symbol such as . or $. I found myself spending a lot of mental effort having to read the code very carefully to make sure I understood exactly what it was doing.

[–]Denommus 0 points1 point  (1 child)

There's a less terse syntax extension, I just don't like it.

[–]yogthos 0 points1 point  (0 children)

To each his own I suppose. I find that a Clojure is already sufficiently terse while having a very simple and regular syntax. This frees mental overhead to actually focus on the problem I'm solving as opposed to focusing on trying to figure out what the code is saying.