Skip to content

Instantly share code, notes, and snippets.

@phadej
Created November 16, 2019 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phadej/af65ce17d1c27640a839abbd8a33746d to your computer and use it in GitHub Desktop.
Save phadej/af65ce17d1c27640a839abbd8a33746d to your computer and use it in GitHub Desktop.
class Convert p c | p -> c, c -> p where
toCabal :: p -> c
fromCabal :: c -> p
instance Convert P.Ver C.Version where
toCabal (P.Ver vs) = C.mkVersion vs
fromCabal v = P.Ver (C.versionNumbers v)
instance Convert P.PkgName C.PackageName where
toCabal (P.PkgName n) = C.mkPackageName (T.unpack n)
fromCabal pn = P.PkgName (T.pack (C.unPackageName pn))
instance Convert P.PkgId C.PackageIdentifier where
toCabal (P.PkgId pn v) = C.PackageIdentifier (toCabal pn) (toCabal v)
fromCabal (C.PackageIdentifier pn v) = P.PkgId (fromCabal pn) (fromCabal v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment