Hoogle Search
Within LTS Haskell 24.32 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
genFromJSONEnum :: Name -> Q [Dec]aeson-schemas Data.Aeson.Schema.TH Generate an instance of FromJSON for the given data type. Prefer using mkEnum; this function is useful for data types in which you want greater control over the actual data type. The FromJSON instance will match to a string value matching the constructor name, case-insensitive.
data State = Open | CLOSED deriving (Show,Enum) genFromJSONEnum ''State -- outputs: -- Just Open -- Just Open -- Just CLOSED -- Just CLOSED main = mapM_ print [ decodeState "open" , decodeState "OPEN" , decodeState "closed" , decodeState "CLOSED" ] where decodeState :: String -> Maybe State decodeState = decode . show
genToJSONEnum :: Name -> Q [Dec]aeson-schemas Data.Aeson.Schema.TH Generate an instance of ToJSON for the given data type. Prefer using mkEnum; this function is useful for data types in which you want greater control over the actual data type. The ToJSON instance will encode the enum as a string matching the constructor name.
data State = Open | CLOSED deriving (Show,Enum) genToJSONEnum ''State -- outputs: -- "Open" -- "CLOSED" main = mapM_ print [ encode Open , encode CLOSED ]
mkEnum :: String -> [String] -> Q [Dec]aeson-schemas Data.Aeson.Schema.TH Make an enum type with the given constructors, that can be parsed from JSON. The FromJSON instance will match to a string value matching the constructor name, case-insensitive.
mkEnum "State" ["OPEN", "CLOSED"] -- generates equivalent of: -- data State = OPEN | CLOSED deriving (...) -- genFromJSONEnum ''State -- genToJSONEnum ''State
getRateNumden :: T i y (Word, Word)alsa-pcm Sound.ALSA.PCM.Parameters.Hardware No documentation available.
-
backprop Numeric.Backprop.Class c'GLFW_INVALID_ENUM :: Num a => abindings-GLFW Bindings.GLFW No documentation available.
stackFrame_lineNumber :: StackFrame -> Intbugsnag-hs Network.Bugsnag The line of the file that this frame of the stack was in.
fromEnum :: Enum a => a -> Intcabal-install-solver Distribution.Solver.Compat.Prelude Convert to an Int. It is implementation-dependent what fromEnum returns when applied to a value that is too large to fit in an Int.
-
cabal-install-solver Distribution.Solver.Compat.Prelude Convert from an Int.
fromEnum :: Enum a => a -> Intclash-prelude Clash.HaskellPrelude Convert to an Int. It is implementation-dependent what fromEnum returns when applied to a value that is too large to fit in an Int.