Skip to content

Conversation

@Bodigrim
Copy link
Collaborator

@Bodigrim Bodigrim commented Dec 16, 2025

The overarching goal is to make Cabal-syntax compilable by MicroHs, which does not support TypeFamilies, but does support FunctionalDependencies. See #11341 for more context.

The only type family Cabal uses is

class Ord (Key a) => IsNode a where
  type Key a
  nodeKey :: a -> Key a
  nodeNeighbors :: a -> [Key a]

This PR changes it to

class Ord keyA => IsNode keyA a | a -> keyA where
  nodeKey :: a -> keyA
  nodeNeighbors :: a -> [keyA]

Ignoring my original motivation for a moment, I think type families do not really bear their weight for class IsNode. Fundeps are more explicit and better to work with: I don't need to evaluate type Key in my head to figure out what's exactly the key, it's right there in type signatures now.

I'll update changelog once this passes CI.

Template Α: This PR modifies behaviour or interface

Include the following checklist in your PR:

The overarching goal is to make Cabal-syntax compilable by MicroHs,
which does not support TypeFamilies, but does support FunctionalDependencies.
@ffaf1
Copy link
Collaborator

ffaf1 commented Dec 16, 2025

Performance issues aside, I find type families easier to understand and reason about than functional dependencies. I believe both researchers and implementators meant type families to replace (among other things) functional dependencies.

Supporting a new compiler is a worthy goal, not a cheap one.
If a decision is made to suppot MicroHs, I would expect a list of allowed/disallowed extensions in CONTRIBUTING.md (or even better, new CI runners).

@geekosaur
Copy link
Collaborator

Hlint can blacklist extensions, fwiw.

@ulysses4ever
Copy link
Collaborator

in the light of #11341 (comment) I suggest to close this PR. In general, I prefer TF over FD for the reason Francesco mentioned: I think they're miles more user-friendly.

@geekosaur
Copy link
Collaborator

I'm slightly in favor of type families.

That said, I should note that multiple Haskell language committees have deadlocked on the question of whether FDs or TFs are the better approach (in the context of standardizing MPTCs); it's not as straightforward as @ffaf1 suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants