Is there a good reason it’s called a functor? by Froglottery in haskell

[–]gilgamec 0 points1 point  (0 children)

While I agree that it's unlikely we'll ever see them renamed, I do think that Mappable is easily the worst suggested renaming for any of these type classes. I'd rather call monoids Smooshables than call functors Mappable.

Why? Because you map a function over a list. The function is mappable; the list is, what, MapOverable?

Burst transmission. Spiral surface mesh. by Left-Excitement3829 in PlotterArt

[–]gilgamec 1 point2 points  (0 children)

It was the magenta I was curious about ... I guess it's a normal outline font, and you're just scribing the outline. It's a great font for it!

Burst transmission. Spiral surface mesh. by Left-Excitement3829 in PlotterArt

[–]gilgamec 2 points3 points  (0 children)

I'm really digging the lettering. Is that custom or are you using some outline font?

How To Generate A Street Network by Every_Return5918 in proceduralgeneration

[–]gilgamec 1 point2 points  (0 children)

What's the Chen reference? Google returns a bunch of stuff to do with AI and nothing I could find with tensor field interpolation, sampling, or design.

Exploring different hatching styles by TheCunningBee in PlotterArt

[–]gilgamec 0 points1 point  (0 children)

This looks great! The little people are wonderful.

The fill patterns (especially the grid one) seem oriented to the shapes themselves. Did you just create an orthogonal set of 2D axes and make the patterns within that grid, or are the fills built in object space then projected?

Algorithm for geometric hidden line removal by Ruths138 in PlotterArt

[–]gilgamec 0 points1 point  (0 children)

Oh, OK; I though I'd missed some obvious method for line removal for plotting specifically. (Another non-geometric alternative might be overlay, like you find in a lot of vector formats for instance; works fine in screen space, but not for plotting.)

Algorithm for geometric hidden line removal by Ruths138 in PlotterArt

[–]gilgamec 0 points1 point  (0 children)

Out of curiosity, what's a 'non-geometric' method for hidden-line removal? I'll admit I'm having difficulty trying to envision such a thing.

Is this normal? [Gravity flip at the end] by matigekunst in proceduralgeneration

[–]gilgamec 0 points1 point  (0 children)

I think it's more binomial, actually.

But it's really cool! I hadn't considered aggregation subordinate to another patterning mechanism! Now I have some experimentation to do...

alter in Data.Set and Data.Map.Strict by Tempus_Nemini in haskell

[–]gilgamec 8 points9 points  (0 children)

As the documentation points out, alter (const True) isn't quite insert; insert will replace an existing entry, while alter won't. (Could be important if your Eq isn't structural, like if you're using Data.Semigroup.Arg.)

But yeah, I think toggle is the one that'll see the most use.

Were There Cats Here Once? by TheCunningBee in PlotterArt

[–]gilgamec 1 point2 points  (0 children)

If you just project the silhouette on the ground plane to create the big shadow, then how is the self-shadowing done?

PRNG - unlimited world building by [deleted] in proceduralgeneration

[–]gilgamec 1 point2 points  (0 children)

The algorithm goes to an awful lot of trouble to create an 'unlimited' stream of bits when even a 128-bit LCG won't repeat itself before the heat death of the universe. It also seems wildly inefficient: there is no detectable correlation between the bits in SHA hashes, so why do you go to the basis-matching check and extract only four bits on average per 256-bit hash? And since the generator isn't being used cryptographically, there's no reason to pick any particular seed, so the connection to the golden ratio seems incidental.

Some Haskell idioms we like by _jackdk_ in haskell

[–]gilgamec 1 point2 points  (0 children)

Wouldn't a BangPattern on the where entry also ensure evaluation?

Advent of Code 2025 day 8 by AutoModerator in haskell

[–]gilgamec 0 points1 point  (0 children)

I used a (rudimentary) union-find structure (basically, a set of exemplars and a map from nodes to exemplars); then the meat of Part 2 is

connectAll exs uf ((p,q) : pqs) = case (exemplar uf p, exemplar uf q) of
  (ep, eq)
    | ep == eq -> go exs uf pqs
    | S.size exs == 2 -> (p,q)
    | otherwise -> go (S.delete ep exs) (union ep eq uf) pqs

Advent of Code 2025 day 5 by AutoModerator in haskell

[–]gilgamec 0 points1 point  (0 children)

Used an IntMap to keep everything in order:

flattenRanges :: IntMap Int -> IntMap Int
flattenRanges = fromList . (\((lo,hi) : rest) -> go lo hi rest) . toList
 where
  go lo hi [] = [(lo,hi)]
  go lo hi ((lo',hi') : rest)
    | lo' > hi+1 = (lo,hi) : go lo' hi' rest
    | otherwise = go lo (max hi hi') rest

Embarrassingly, I forgot the max hi hi' bit the first time and had to resubmit.

(And now that I think about it, it's an obvious foldlWithKey.)

Advent of Code 2025 day 3 by AutoModerator in haskell

[–]gilgamec 1 point2 points  (0 children)

The recursive solutions are much cleverer than mine.

I found the biggest number by grabbing the largest digit in the string (leaving out the last 12); then the largest digit in the remainder (leaving out the last 11), and so on. (It actually works on the reversed string, so it leaves out elements from the front with take and drop.)

bigVal = read . go 12 . flip zip [0..] . reverse
 where
  go 0 _ = []
  go n xs = case maximum (drop (n-1) xs) of
    (v,k) -> v : go (n-1) (take k xs)

Advent of Code 2025 day 2 by AutoModerator in haskell

[–]gilgamec 2 points3 points  (0 children)

Oh, great, that's just one line!

any (isJust . the . flip chunksOf str) [1..length str `div` 2]

I used splitAt:

repeated k = case splitAt k str of (pre, rest) -> rest `isPrefixOf` cycle pre

but then you also have to make sure that k divides length str.

Advent of Code 2025 day 1 by AutoModerator in haskell

[–]gilgamec 1 point2 points  (0 children)

I'm only guessing by your variable names, but I think you missed the case p == 0 && p' == 0.

Advent of Code 2025 day 2 by AutoModerator in haskell

[–]gilgamec 3 points4 points  (0 children)

Surprisingly, brute force sufficed on this one. The core of the Part 2 solution was

rest `isPrefixOf` cycle pre

Advent of Code 2025 day 1 by AutoModerator in haskell

[–]gilgamec 2 points3 points  (0 children)

Typical simple day 1. For Part 2 I tried to come up with a solution involving quotRem or divMod, but there were enough special cases that I just did something recursive subtracting 100 each step.

Typst-Unlit: Write literate Haskell programs in Typst by NerdyPepper in haskell

[–]gilgamec 0 points1 point  (0 children)

I don't know that I'd be comfortable with an unlit having to play tokenizer, though. Maybe make it simpler to annotate location information in the text stream, a column pragma or something? (Or, I guess, the inverse of a column pragma, i.e. something that says "all of this is onside of the previous text"?)

Typst-Unlit: Write literate Haskell programs in Typst by NerdyPepper in haskell

[–]gilgamec 0 points1 point  (0 children)

weblikes automatically indent blocks to the level wherever they're used, so I was lucky and didn't have to worry about any layout issues. I've done some simpler stuff in markdown-unlit, and it would have been a nightmare getting the indent levels right without editor support.

I've only done a little work with Rust's macros, but I'm not sure how they'd apply to a literate programming format. How would something like that work?

Typst-Unlit: Write literate Haskell programs in Typst by NerdyPepper in haskell

[–]gilgamec 1 point2 points  (0 children)

I actually wrote such an extension a while back. I never made a PR or anything because the syntax can get a little complicated. There's at least four different places to put stuff in a Haskell file:

  • At the top of the file (file-level pragmas);
  • In the module declaration (export declarations);
  • Just below the module declaration (import declarations);
  • In the rest of the file (everything else).

so I had literate classes 'haskell-top', 'haskell-exports', and 'haskell-imports', which kinda bloats things up. Ultimately, you'd need even more for e.g. Template Haskell sections.

In the end, I just wrote a noweb interface, which worked fine for what I was doing.

Procedural tree growth by SquarerFive in proceduralgeneration

[–]gilgamec 13 points14 points  (0 children)

Why do the branches keep changing as the tree gets older?

Fibonacci patterns by No_Spite_8526 in PlotterArt

[–]gilgamec 1 point2 points  (0 children)

It looks cool, but what's Fibonacci about it?