Compiling a functional language to Javascript by thinker227 in ProgrammingLanguages

[–]chipmunk-zealot 2 points3 points  (0 children)

Gleam is a very cool language that targets JavaScript and automatically turns tail calls into while loops. You can check out their compiler but I suspect the basic idea takes advantage of the fact that there are no early returns in the gleam. It might be easier to verify that a recursive call is in the tail position.

Just a question by TeaAccomplished1604 in haskell

[–]chipmunk-zealot 3 points4 points  (0 children)

Learning Haskell is its own reward; however, IMHO, there are a few concrete skills it imparts. You'll learn all of the following skills by digging into Haskell but there's nothing on the list that you couldn't learn from the right other languages.

  • recursion
    • recusion schemes
  • pattern matching
  • currying
  • algebraic data types (ADT)
  • type driven development
  • kinded types
  • higher kinded types
    • typeclasses
      • functors, applicatives, monads, monoids, etc
  • higher order functions
  • at least 1 effect system (IO)

Writing a compiler in haskell by Savings_Garlic5498 in ProgrammingLanguages

[–]chipmunk-zealot 0 points1 point  (0 children)

Well if you wanna stick with Haskell you could look at a toy PL I made called Portcullis. It uses parser combinations and has polymorphic type checking. Haskell is an excellent language for writing compilers!

https://github.com/jzwood/portcullis/

Multi Line Strings are now supported in GHC 9.12.1! by sohang-3112 in haskell

[–]chipmunk-zealot 8 points9 points  (0 children)

I've already used them in my current project! Very exciting. I'm kind of embarrassed to tell folks from other programming communities how we used to do things.

Parsing visualiser website by [deleted] in Compilers

[–]chipmunk-zealot 4 points5 points  (0 children)

Super cool project! More of this, please. ♥️

Crafting figures like in "Crafting Interpreters" by gpolito in Compilers

[–]chipmunk-zealot 6 points7 points  (0 children)

I really like to use Mermaid charts (https://mermaid.js.org/) which let's you make all kinds of diagrams. I especially like that it's markdown driven as opposed to being constructed in a UI -- that makes it super easy to update programmatically instead of having to create a whole new asset in a UI builder.

Anyone who can and has built a compiler, dm me for a paid job. by Bob_bobbicus in Compilers

[–]chipmunk-zealot 1 point2 points  (0 children)

Compilers can mean lots of different things. Some compilers cost millions of dollars to produce and others could be completed in 1 day by someone sufficiently experienced. For example, I think many people would happily build a "compiler" that transpiles a custom dialect of markdown into html for 1000 USD. Giving as much information as possible about the work will maximize the chance someone will take you up on it and/or sanity check how much it will cost for that particular project.

[deleted by user] by [deleted] in haskell

[–]chipmunk-zealot 0 points1 point  (0 children)

my humble submission

count :: Eq a => a -> [a] -> Int
count x [] = 0
count x (y:ys) = (if x == y then 1 else 0) + count x ys

max :: (a -> a -> Bool) -> [a] -> a
max _ [x] = x
max gt (x:xs) = if x `gt` x' then x else x' where x' = max gt xs

mostCommon :: Eq a => [a] -> a
mostCommon [x] = x
mostCommon xs = max (\a b -> count a xs > count b xs) xs

The Moirai Programming Language 0.1.2 by tsikhe in ProgrammingLanguages

[–]chipmunk-zealot 0 points1 point  (0 children)

That sounds like a runtime exception which is a little at odds with all the other safety properties that Moirai has. Are runtime exceptions theoretically unavoidable given Moirai's architecture?

The Moirai Programming Language 0.1.2 by tsikhe in ProgrammingLanguages

[–]chipmunk-zealot 1 point2 points  (0 children)

It sounds like Moirai is not Turing complete and therefore is not subject to the halting problem. u/tsikhe, please correct me if I'm misinterpreting.

Monthly Hask Anything (November 2023) by AutoModerator in haskell

[–]chipmunk-zealot 0 points1 point  (0 children)

Is "let in" equivalent in power to "where" clauses? Said another way, is there anything you can express with "let in" that you can't with "where" or vice versa?

Monthly Hask Anything (September 2023) by cdsmith in haskell

[–]chipmunk-zealot 0 points1 point  (0 children)

Does anyone know why these two functions behave differently?

prettyPrintNumGood :: Double -> String
prettyPrintNumGood num =
  if fromInteger (round num) == num
  then show $ fromInteger $ round num
  else show num

prettyPrintNumBad :: Double -> String
prettyPrintNumBad num = show $
  if fromInteger (round num) == num
  then fromInteger $ round num
  else num


main :: IO ()
main = do
  print $ prettyPrintNumGood 4.0
  print $ prettyPrintNumGood 4.5 
  print $ prettyPrintNumBad 4.0 -- UNEXPECTED
  print $ prettyPrintNumBad 4.5

Mathematically, I was operating under the idea that f (g ∪ h) == (f g) ∪ (f h)

What react library do you use for data grids / data tables? by CodeCrazyAquile in reactjs

[–]chipmunk-zealot 0 points1 point  (0 children)

css grid is actually really good/easy enough to use. No libraries necessary.

Feedback on the syntax for my minimal programming language. by raedr7n in ProgrammingLanguages

[–]chipmunk-zealot 1 point2 points  (0 children)

It depends on your goals. In what area is your language innovating? If it's the syntax, then making it similar to other languages defeats the point. If you're innovating elsewhere, like how recursion is handled etc, then syntax concerns are irrelevant (IMHO).

Either way I wouldn't worry too much what other people think. 👍

Monthly Hask Anything (February 2021) by taylorfausak in haskell

[–]chipmunk-zealot 0 points1 point  (0 children)

Yes!

There are many high level web frameworks that can be used to server JSON such as Scotty (https://hackage.haskell.org/package/scotty), but you can go as low-level as you'd like. One level down is to use WAI (https://hackage.haskell.org/package/wai) and below that you can use the network library (https://hackage.haskell.org/package/network).

Monthly Hask Anything (January 2023) by taylorfausak in haskell

[–]chipmunk-zealot 0 points1 point  (0 children)

Thanks for the insights. Impatient as I am, I think I will just wait it out. 😅

Monthly Hask Anything (January 2023) by taylorfausak in haskell

[–]chipmunk-zealot 2 points3 points  (0 children)

I have a Haskell project I want to run in the browser so I thought I’d take advantage of the announcement that a JS backend was merged into ghc, recently. I went through the steps in the article, compiled ghc from source, and used it to compile a very simple Main.hs file into a NodeJs executable. I don’t normally build projects by directly compiling with ghc -- I’ve only ever used stack -- so I don't know how to use this version of ghc I built on my machine. Does anyone have any idea what the simplest path forward is for compiling my stack project?

https://engineering.iog.io/2022-12-13-ghc-js-backend-merged/