Created
December 9, 2015 19:51
-
-
Save glasserc/f4788dbd74a26b4ad2ae to your computer and use it in GitHub Desktop.
running formatters on some code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module SumAll.Eureka.Types (EitherStyleListeners(..)) where | |
import Canteven.Listen.HTTP | |
(ListenerConfig, ListenHTTPConfig(ListenHTTPConfig), otherthing, | |
moyonthetnh) | |
import qualified Canteven.Listen.HTTP as CLH | |
(ListenHTTPConfig(listeners)) | |
import Control.Applicative ((<|>)) | |
import Data.Aeson (FromJSON(parseJSON), (.:), withObject) | |
import Data.Functor ((<$>)) | |
import GHC.Generics (Generic) | |
-- This is a work-around. Instead of exposing the ServerConfig datatypes in | |
-- Moonshine, we reparse the same Moonshine "applicationConnector" field using | |
-- canteven-listen-http types. | |
data ServerConfig = | |
ServerConfig {applicationConnector :: [ListenerConfig]} | |
deriving (Show,Generic) | |
instance FromJSON ServerConfig | |
newtype EitherStyleListeners = | |
EitherStyleListeners {listeners :: [ListenerConfig]} | |
deriving (Eq,Show) | |
instance FromJSON EitherStyleListeners where | |
parseJSON v = | |
EitherStyleListeners <$> (parseAsListenHTTPConfig <|> parseAsMoonshine) | |
where parseAsListenHTTPConfig = | |
do ListenHTTPConfig{CLH.listeners = lhcListeners} <- parseJSON v | |
return lhcListeners | |
parseAsMoonshine = | |
flip (withObject "ServerConfig") v $ | |
\obj -> | |
do ServerConfig{applicationConnector} <- obj .: "server" | |
return applicationConnector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module SumAll.Eureka.Types (EitherStyleListeners(..)) where | |
import Canteven.Listen.HTTP (ListenerConfig, | |
ListenHTTPConfig(ListenHTTPConfig), | |
otherthing, moyonthetnh) | |
import qualified Canteven.Listen.HTTP as CLH (ListenHTTPConfig(listeners)) | |
import Control.Applicative ((<|>)) | |
import Data.Aeson (FromJSON(parseJSON), (.:), withObject) | |
import Data.Functor ((<$>)) | |
import GHC.Generics (Generic) | |
-- This is a work-around. Instead of exposing the ServerConfig datatypes in | |
-- Moonshine, we reparse the same Moonshine "applicationConnector" field using | |
-- canteven-listen-http types. | |
data ServerConfig = ServerConfig { applicationConnector :: [ListenerConfig] } | |
deriving (Show, Generic) | |
instance FromJSON ServerConfig | |
newtype EitherStyleListeners = | |
EitherStyleListeners | |
{ listeners :: [ListenerConfig] } | |
deriving (Eq, Show) | |
instance FromJSON EitherStyleListeners where | |
parseJSON v = | |
EitherStyleListeners <$> (parseAsListenHTTPConfig <|> parseAsMoonshine) | |
where | |
parseAsListenHTTPConfig = do | |
ListenHTTPConfig { CLH.listeners = lhcListeners } <- parseJSON v | |
return lhcListeners | |
parseAsMoonshine = | |
flip (withObject "ServerConfig") v $ | |
\obj -> do | |
ServerConfig { applicationConnector } <- obj .: "server" | |
return applicationConnector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module SumAll.Eureka.Types (EitherStyleListeners(..)) where | |
import Canteven.Listen.HTTP | |
(ListenerConfig, ListenHTTPConfig(ListenHTTPConfig), otherthing, | |
moyonthetnh) | |
import qualified Canteven.Listen.HTTP as CLH | |
(ListenHTTPConfig(listeners)) | |
import Control.Applicative ((<|>)) | |
import Data.Aeson (FromJSON(parseJSON), (.:), withObject) | |
import Data.Functor ((<$>)) | |
import GHC.Generics (Generic) | |
-- This is a work-around. Instead of exposing the ServerConfig datatypes in | |
-- Moonshine, we reparse the same Moonshine "applicationConnector" field using | |
-- canteven-listen-http types. | |
data ServerConfig = ServerConfig | |
{ applicationConnector :: [ListenerConfig] | |
} deriving (Show,Generic) | |
instance FromJSON ServerConfig | |
newtype EitherStyleListeners = EitherStyleListeners | |
{ listeners :: [ListenerConfig] | |
} deriving (Eq,Show) | |
instance FromJSON EitherStyleListeners where | |
parseJSON v = | |
EitherStyleListeners <$> (parseAsListenHTTPConfig <|> parseAsMoonshine) | |
where | |
parseAsListenHTTPConfig = do | |
ListenHTTPConfig{CLH.listeners = lhcListeners} <- parseJSON v | |
return lhcListeners | |
parseAsMoonshine = | |
flip (withObject "ServerConfig") v $ | |
\obj -> | |
do ServerConfig{applicationConnector} <- obj .: "server" | |
return applicationConnector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module SumAll.Eureka.Types (EitherStyleListeners(..)) where | |
import Canteven.Listen.HTTP (ListenHTTPConfig (ListenHTTPConfig), | |
ListenerConfig, moyonthetnh, otherthing) | |
import qualified Canteven.Listen.HTTP as CLH (ListenHTTPConfig (listeners)) | |
import Control.Applicative ((<|>)) | |
import Data.Aeson (FromJSON (parseJSON), withObject, (.:)) | |
import Data.Functor ((<$>)) | |
import GHC.Generics (Generic) | |
-- This is a work-around. Instead of exposing the ServerConfig datatypes in | |
-- Moonshine, we reparse the same Moonshine "applicationConnector" field using | |
-- canteven-listen-http types. | |
data ServerConfig = | |
ServerConfig {applicationConnector :: [ListenerConfig]} | |
deriving (Show,Generic) | |
instance FromJSON ServerConfig | |
newtype EitherStyleListeners = | |
EitherStyleListeners {listeners :: [ListenerConfig]} | |
deriving (Eq,Show) | |
instance FromJSON EitherStyleListeners where | |
parseJSON v = | |
EitherStyleListeners <$> (parseAsListenHTTPConfig <|> parseAsMoonshine) | |
where parseAsListenHTTPConfig = | |
do ListenHTTPConfig{CLH.listeners = lhcListeners} <- parseJSON v | |
return lhcListeners | |
parseAsMoonshine = | |
flip (withObject "ServerConfig") v $ | |
\obj -> | |
do ServerConfig{applicationConnector} <- obj .: "server" | |
return applicationConnector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module SumAll.Eureka.Types ( | |
EitherStyleListeners(..), | |
) where | |
import Canteven.Listen.HTTP (ListenerConfig, | |
ListenHTTPConfig(ListenHTTPConfig), otherthing, moyonthetnh) | |
import qualified Canteven.Listen.HTTP as CLH (ListenHTTPConfig(listeners)) | |
import Control.Applicative ((<|>)) | |
import Data.Aeson (FromJSON(parseJSON), (.:), withObject) | |
import Data.Functor ((<$>)) | |
import GHC.Generics (Generic) | |
-- This is a work-around. Instead of exposing the ServerConfig datatypes in | |
-- Moonshine, we reparse the same Moonshine "applicationConnector" field using | |
-- canteven-listen-http types. | |
data ServerConfig = ServerConfig { | |
applicationConnector :: [ListenerConfig] | |
} deriving (Show, Generic) | |
instance FromJSON ServerConfig | |
newtype EitherStyleListeners = EitherStyleListeners { | |
listeners :: [ListenerConfig] | |
} deriving (Eq, Show) | |
instance FromJSON EitherStyleListeners where | |
parseJSON v = EitherStyleListeners <$> | |
(parseAsListenHTTPConfig <|> parseAsMoonshine) | |
where | |
parseAsListenHTTPConfig = do | |
ListenHTTPConfig {CLH.listeners = lhcListeners} <- parseJSON v | |
return lhcListeners | |
parseAsMoonshine = flip (withObject "ServerConfig") v $ \obj -> do | |
ServerConfig {applicationConnector} <- obj .: "server" | |
return applicationConnector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module SumAll.Eureka.Types (EitherStyleListeners(..)) where | |
import Canteven.Listen.HTTP | |
(ListenHTTPConfig(ListenHTTPConfig), ListenerConfig, moyonthetnh, | |
otherthing) | |
import qualified Canteven.Listen.HTTP as CLH (ListenHTTPConfig(listeners)) | |
import Control.Applicative ((<|>)) | |
import Data.Aeson ((.:), FromJSON(parseJSON), withObject) | |
import Data.Functor ((<$>)) | |
import GHC.Generics (Generic) | |
-- This is a work-around. Instead of exposing the ServerConfig datatypes in | |
-- Moonshine, we reparse the same Moonshine "applicationConnector" field using | |
-- canteven-listen-http types. | |
data ServerConfig = ServerConfig{applicationConnector :: [ListenerConfig]} | |
deriving (Show, Generic) | |
instance FromJSON ServerConfig | |
newtype EitherStyleListeners = EitherStyleListeners{listeners :: | |
[ListenerConfig]} | |
deriving (Eq, Show) | |
instance FromJSON EitherStyleListeners where | |
parseJSON v | |
= EitherStyleListeners <$> (parseAsListenHTTPConfig <|> parseAsMoonshine) | |
where | |
parseAsListenHTTPConfig | |
= do ListenHTTPConfig{CLH.listeners = lhcListeners} <- parseJSON v | |
return lhcListeners | |
parseAsMoonshine | |
= flip (withObject "ServerConfig") v $ | |
\ obj -> | |
do ServerConfig{applicationConnector} <- obj .: "server" | |
return applicationConnector |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment