Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

list of unions not converted to maps #71

Open
alexhumphreys opened this issue Nov 23, 2018 · 3 comments
Open

list of unions not converted to maps #71

alexhumphreys opened this issue Nov 23, 2018 · 3 comments

Comments

@alexhumphreys
Copy link

I'm writing some GoCD pipeline configs in dhall and ran into the following issue. Given this dhall file:

let MaterialSource =
  { mapKey : Text
  , mapValue :
    { git : Text
    , branch : Text
    }
  }
in let MaterialPipeline =
  { mapKey : Text
  , mapValue :
    { pipeline : Text
    , stage : Text
    }
  }
in let Material = < Source : MaterialSource | Pipeline : MaterialPipeline >
in let unionMaterial = constructors Material
in let Materials = List Material
in let materials : Materials =
  [ unionMaterial.Source
    { mapKey = "someRepo"
    , mapValue =
      { git = "www.example.com/user/repo.git"
      , branch = "master"
      }
    }
  , unionMaterial.Pipeline
    { mapKey = "somePipeline"
    , mapValue =
      { pipeline = "someOtherPipeline"
      , stage = "build"
      }
    }
  ]
in materials

I get this output:

- mapKey: someRepo
  mapValue:
    branch: master
    git: www.example.com/user/repo.git
- mapKey: somePipeline
  mapValue:
    stage: build
    pipeline: someOtherPipeline

whereas I would have expected:

someRepo:
    branch: master
    git: www.example.com/user/repo.git
somePipeline:
    stage: build
    pipeline: someOtherPipeline

I'm new to dhall so it's likely i'm doing something wrong, any help would be appreciated.

@f-f
Copy link
Member

f-f commented Nov 23, 2018

Hi @alexhumphreys! The development of dhall-json has moved to dhall-haskell, so maybe we could move that issue there.

This said, I believe you are right and this is currently not supported. In fact, it looks like the homogeneous records conversion is applied specifically to lists, while unions go through unconverted.
I think the conversion logic could be pulled out and applied in other places, but need to think how far we can take this 🤔

@alexhumphreys
Copy link
Author

Hey @f-f, thanks for the heads up about the move, i'll copy paste this issue over there and close it here. And yeah adding support for this would be cool, though I can imagine there might be some work involved alright.

@Gabriella439
Copy link
Collaborator

Yeah, I will need to go through the merged repositories and mark them clearly so that people know that they have been migrated

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants