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
Path
datatype. Even though thePath
constructor is not exposed it still provides aGeneric
instance, which is enough for theFromDhall
instance to derive something.In this case, since
Path
is internally defined as:… then the derived
FromDhall
instance 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
FromDhall
instance yourself.So what you will probably want to write is something like: