packages feed

battleplace-0.1.0.9 / BattlePlace / Util.hs

{-|Module: BattlePlace.UtilDescription: General utilities.License: MIT-}{-# LANGUAGE LambdaCase #-}module BattlePlace.Util	( jsonOptions	, jsonOptionsWithTag	) whereimport qualified Data.Aeson as JjsonOptions :: J.OptionsjsonOptions = jsonOptionsWithTag "status"jsonOptionsWithTag :: String -> J.OptionsjsonOptionsWithTag tag = J.defaultOptions	{ J.fieldLabelModifier = dropBeforeUnderscore	, J.constructorTagModifier = dropBeforeUnderscore	, J.sumEncoding = J.TaggedObject		{ J.tagFieldName = tag		, J.contentsFieldName = "contents"		}	}dropBeforeUnderscore :: String -> StringdropBeforeUnderscore = \case	x : xs -> case x of		'_' -> xs		_ -> dropBeforeUnderscore xs	[] -> []