Skip to content

Commit

Permalink
Fix sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj committed Jul 2, 2024
1 parent 4c07c8e commit 8c7df18
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Stratosphere/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,33 +100,33 @@ mkFunc key args = JSON.object [(key, JSON.Array $ fromList args)]
-- @List<AWS::EC2::Subnet::Id>@ then, you can use @RefList "SubnetIds"@ to
-- reference it.
data ValueList a
= ValueList [Value a]
| RefList Text
= GetAZs (Value Text)
| ImportValueList (Value Text)
| RefList Text
| Split Text (Value a)
| GetAZs (Value Text)
| ValueList [Value a]
deriving (Show, Eq)

instance IsList (ValueList a) where
type Item (ValueList a) = Value a
fromList = ValueList

toList = \case
(ValueList xs) -> xs
-- This is obviously not meaningful, but the IsList instance is so useful
-- that I decided to allow it.
(RefList _) -> []
(GetAZs _) -> []
(ImportValueList _) -> []
(RefList _) -> []
(Split _ _) -> []
(GetAZs _) -> []
-- This is obviously not meaningful, but the IsList instance is so useful
-- that I decided to allow it.
(ValueList xs) -> xs

instance JSON.ToJSON a => JSON.ToJSON (ValueList a) where
toJSON = \case
(ValueList vals) -> JSON.toJSON vals
(RefList ref) -> refToJSON ref
(GetAZs r) -> JSON.object [("Fn::GetAZs", JSON.toJSON r)]
(ImportValueList ref) -> importValueToJSON ref
(RefList ref) -> refToJSON ref
(Split d s) -> mkFunc "Fn::Split" [JSON.toJSON d, JSON.toJSON s]
(GetAZs r) -> JSON.object [("Fn::GetAZs", JSON.toJSON r)]
(ValueList vals) -> JSON.toJSON vals

-- | Class used to create a 'Ref' from another type.
class ToRef a b where
Expand Down

0 comments on commit 8c7df18

Please sign in to comment.