summaryrefslogtreecommitdiff
path: root/src/Language/PureScript/Names.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Language/PureScript/Names.hs')
-rw-r--r--src/Language/PureScript/Names.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Language/PureScript/Names.hs b/src/Language/PureScript/Names.hs
index e2327c1..5f8afd7 100644
--- a/src/Language/PureScript/Names.hs
+++ b/src/Language/PureScript/Names.hs
@@ -12,6 +12,7 @@ import Prelude.Compat
import Control.Monad.Supply.Class
import Control.DeepSeq (NFData)
+import Data.Functor.Contravariant (contramap)
import GHC.Generics (Generic)
import Data.Aeson
@@ -243,3 +244,9 @@ isQualifiedWith _ _ = False
$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''Qualified)
$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''Ident)
$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ModuleName)
+
+instance ToJSONKey ModuleName where
+ toJSONKey = contramap runModuleName toJSONKey
+
+instance FromJSONKey ModuleName where
+ fromJSONKey = fmap moduleNameFromString fromJSONKey