I was trying to make an instance for the Path type. https://hackage.haskell.org/package/path
If I use the generic.
instance FromDhall (Path Rel Dir)
This doesn't do any normalisation of directories. I initially assumed this would piggyback off the defined FromJSON instances which in turn call parseRelDir etc, but that's not the case, and when I tried to implement this manually I realised I'm quite in over my head. What's the way to do this?
The derived instance will use the shape of the
Pathdatatype. Even though thePathconstructor is not exposed it still provides aGenericinstance, which is enough for theFromDhallinstance to derive something.In this case, since
Pathis internally defined as:… then the derived
FromDhallinstance will expect a Dhall value of something like this type:… which is the derived Dhall type for a data type with 1 anonymous field that is a
String/FilePath.This is probably not what you wanted (as you noted), so if you want different behavior you will need to implement the
FromDhallinstance yourself.So what you will probably want to write is something like: