[Haskell-cafe] Runtime selection on types while capturing a dictionary?

Tom Ellis tom-lists-haskell-cafe-2023 at jaguarpaw.co.uk
Wed Oct 9 07:40:35 UTC 2024


On Wed, Oct 09, 2024 at 09:33:30AM +0200, Andreas Källberg wrote:
> 
> > On 8 Oct 2024, at 00:14, Tom Ellis <tom-lists-haskell-cafe-2023 at jaguarpaw.co.uk> wrote:
> >    data PossiblyRootedTree lengths labels where
> >        RootedTree :: AugmentedTree [NodeId] lengths labels
> >        UnrootedTree :: AugmentedTree () lengths labels
> 
> Isn’t that invalid syntax? Wouldn’t you need either
> 
> data PossiblyRootedTree lengths labels where
>        RootedTree :: AugmentedTree [NodeId] lengths labels -> PossiblyRootedTree lengths labels 
>        UnrootedTree :: AugmentedTree () lengths labels  -> PossiblyRootedTree lengths labels
> 
> or simply (avoiding GADT syntax altogether):
> 
> data PossiblyRootedTree lengths labels =
>        RootedTree (AugmentedTree [NodeId] lengths labels)
>        | UnrootedTree (AugmentedTree () lengths labels)

Yes, you're right, thanks (and I'm not sure why I thought that
required a GADT).

Tom


More information about the Haskell-Cafe mailing list