Polymorphizing a graph of types - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Asad Saeeduddin

Anyone know of a library that can take some type definitions like this:

data ABC
  = A A
  | B B
  | C C

data A = A { a1 :: Int, a2 :: String }

data B = B { b1 :: String }

data C = C { c1 :: Int, c2 :: Int, c3 :: String }

and with the least amount of work possible, give me equivalent definitions with certain positions substituted with type parameters? e.g. suppose I want to have a2 and c3 substituted with type parameters, which should give me:

data ABC s
  = A (A s)
  | B B
  | C (C s)

data A s = A { a1 :: Int, a2 :: s }

data B = B { b1 :: String }

data C s = C { c1 :: Int, c2 :: Int, c3 :: s }
Georgi Lyubenov // googleson78

did you check out if retrie supports something like this?

Georgi Lyubenov // googleson78

I kind of doubt it, but that's the only thing that comes to mind

bradrn

Hold on, how do those definitions make sense? Surely they’d give an error about multiple declarations? (Unless this is meant to be some sort of pseudocode-ish simplification…)

Pedro Minicz

I believe it is supposed to be pseudocode, but it is unfortunate Haskell doesn't accept overloading constructors like Agda does.