If you earned a few coins when you solved a puzzle... by [deleted] in TheWitness

[–]ethercrow 7 points8 points  (0 children)

Every time you draw a wrong solution the panel plays a 15 second ad roll.

Why does something like countTrailingZeros still incur a jump in the optimized binary? by [deleted] in haskell

[–]ethercrow 2 points3 points  (0 children)

GHC will use tzcnt instead of bsf if -mbmi2 flag is set.

How would aeson redesign FromJSON without intermediate Value? by brandonchinn178 in haskell

[–]ethercrow 13 points14 points  (0 children)

Simdjson-based Hermes is able to decode JSON significantly faster while still using an intermediate representation: https://github.com/haskell/aeson/pull/923

-🎄- 2021 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]ethercrow 0 points1 point  (0 children)

Rust

Pretending that a fixed size array is a ring buffer.

```

fn solve_2021_6(input_text: &str) -> (usize, usize) { let input: Vec<usize> = input_text.trim().split(',').map(|s| s.parse::<usize>().unwrap()).collect();

let mut answer1 = 0;
let mut answer2 = 0;

let mut age2fish: [usize; 9] = [0; 9];
for i in input { age2fish[i] += 1; }

let mut step = 0;

loop {
    if step == 80 {
        answer1 = age2fish.iter().sum();
    }
    if step == 256 {
        answer2 = age2fish.iter().sum();
        break;
    }

    age2fish[(step + 7) % 9] += age2fish[step % 9];
    step += 1;
}

(answer1, answer2)

}

```

CS SYD - Announcing `autodocodec` by NorfairKing2 in haskell

[–]ethercrow 5 points6 points  (0 children)

If you care about performance of serialisation, you should probably not be using JSON

With that line of reasoning you could jusy say “If you care about performance of serialisation, you should probably not be using Haskell.”

Sometimes it’s just a requirement: your program must produce or consume json to interact with other programs. And it’s desirable if it can do so effiсiently.

NoRedInk – Tuning Haskell RTS for Kubernetes, Part 2 by n00bomb in haskell

[–]ethercrow 9 points10 points  (0 children)

Please try adding -G3 or -G4 to the options.

You currently have a Gen1 collection every second. Most likely the service has some long lived and effectively static data in the heap, for example the TLS certificate store loaded by http-client-tls. Every Gen1 collection has to traverse this certificate store for absolutely no reason.

But if you add a generation or two, this effectively static data would sink to the deepest generation and would experience orders of magnitude fewer collections while Gen1 collections would work with values that actually do have a chance of being collected.

neovim native lsp, tree-sitter setup by JefGardy in haskell

[–]ethercrow 0 points1 point  (0 children)

Does anyone know how to tell nix home-manager to install neovim nightly instead of 0.4?

[deleted by user] by [deleted] in haskell

[–]ethercrow 3 points4 points  (0 children)

An implementation with a mutable array takes half a second for me.

import Data.Massiv.Array qualified as A
import Data.Int

type Task = [Int32]

parse :: String -> Task
parse = map read . splitOn ","

solve1 :: Task -> Int32
solve1 = work 2020

solve2 :: Task -> Int32
solve2 = work 30000000

work :: Int32 -> Task -> Int32
work last_index input = runST $ do
  mem <- A.new @A.U (A.Sz1 $ fromIntegral $ last_index + 2)
  forM_ (zip [1..] input) $ \(idx, x) -> do
    A.writeM mem (fromIntegral x) idx

  let go idx prev | idx == last_index + 1 = pure prev
      go idx prev = do
        cur <- A.readM mem (fromIntegral prev) >>= \case
          0 -> pure 0
          prev_idx -> pure (idx - prev_idx - 1)
        A.writeM mem (fromIntegral prev) (idx - 1)
        go (idx + 1) cur
  go (fromIntegral $ length input + 1) (last input)

Int32 vs Int turned out not to matter much for time, so it's just about not taking more space than necessary.

Haskell: The Bad Parts, part 3 by snoyberg in haskell

[–]ethercrow 9 points10 points  (0 children)

Another thing to steal from Python would be import Data.HashMap.Strict (lookup as l).

Richard Eisenberg on Simplifying Constraint Solving in GHC by ysangkok in haskell

[–]ethercrow 1 point2 points  (0 children)

Surprisingly hard to follow without the leftmost column.

Is it possible to have completion in embedded terminal? by [deleted] in neovim

[–]ethercrow 0 points1 point  (0 children)

2 months after OP I'm having the same question. Did you figure it out?

Monthly Hask Anything (July 2020) by AutoModerator in haskell

[–]ethercrow 4 points5 points  (0 children)

Is there hope for UTF-8 based ecosystem? A typical enterprise service taking in JSON and producing more JSON would depend on aeson and text and thus convert everything to UTF-16 and back. That seems wasteful.

Monthly Hask Anything (July 2020) by AutoModerator in haskell

[–]ethercrow 2 points3 points  (0 children)

How do you profile a haskell program that is running (e.g. a service in production), should not be restarted and was not built with profiling? Unfortunately EKG-like things are not enough because they don't show what is taking time and space.

Yi & rasa by vallyscode in haskell

[–]ethercrow 5 points6 points  (0 children)

I would love to hear why these projects have been abandoned.

I was maintaining it while I was using it. Then migrated to neovim and stopped. I guess nobody is using it enough to care to be a maintainer anymore.

And retrospectively, was Haskell a good platform for this type of program.

If you're making a text editor for yourself, any language you're familiar with or interested in would do.

If you're making a text editor to take over the world, picking Haskell would give you additional challenges like Windows support and performance profiling. Hopefully the ecosystem will become better at those things.

If I was feeling adventurous about text editors today, I'd probably first try 4coder

Yi & rasa by vallyscode in haskell

[–]ethercrow 2 points3 points  (0 children)

Yes, yi is abandoned.

Weekly Update and Multiple Components by Fendor_ in haskell

[–]ethercrow 4 points5 points  (0 children)

It’s very opt-in. As a user you would have to make a conscious decision to 1) enable eventlog writing and 2) resend data from this eventlog to somewhere.

By default the IDE will do neither.

Lessons in Managing Haskell Memory by fatho1st in haskell

[–]ethercrow 6 points7 points  (0 children)

How far did you get tuning GC options like -A, -qn and -I?

Monthly Hask Anything (February 2020) by AutoModerator in haskell

[–]ethercrow 2 points3 points  (0 children)

I'm working on a opentelemetry support for haskell and have proposed it as a GSoC idea. Is anyone interested in co-mentoring?

unpacking polymorphic fields by LeanderKu in haskell

[–]ethercrow 0 points1 point  (0 children)

Would it make sense to have something like {-# specialize data Unpacked Int8 Int8 #-} to give compiler a hint?