parseRangeValue :: ( FromJSON t4
                   , FromJSON t3
                   , FromJSON t2
                   , FromJSON t1
                   )
                => (t3 -> t5)
                -> (t1 -> t6)
                -> (t4 -> t7)
                -> (t2 -> t8)
                -> (t5 -> t6 -> b)
                -> (t7 -> t6 -> b)
                -> (t5 -> t8 -> b)
                -> (t7 -> t8 -> b)
                -> (t5 -> b)
                -> (t6 -> b)
                -> (t7 -> b)
                -> (t8 -> b)
                -> Parser b
                -> Object
                -> Parser b
parseRangeValue mkGt mkLt mkGte mkLte
                fGtLt fGteLt fGtLte fGteLte
                fGt fLt fGte fLte nada o = do
  lt <- o .:? "lt"
  lte <- o .:? "lte"
  gt <- o .:? "gt"
  gte <- o .:? "gte"
  case (lt, lte, gt, gte) of
    (Just a, _, Just b, _) ->
      return (fGtLt (mkGt b) (mkLt a))
    (Just a, _, _, Just b) ->
      return (fGteLt (mkGte b) (mkLt a))
    (_, Just a, Just b, _) ->
      return (fGtLte (mkGt b) (mkLte a))
    (_, Just a, _, Just b) ->
      return (fGteLte (mkGte b) (mkLte a))
    (_, _, Just a, _) ->
      return (fGt (mkGt a))
    (Just a, _, _, _) ->
      return (fLt (mkLt a))
    (_, _, _, Just a) ->
      return (fGte (mkGte a))
    (_, Just a, _, _) ->
      return (fLte (mkLte a))
    (Nothing, Nothing, Nothing, Nothing) ->
      nada
parseRangeValue :: ( FromJSON t4
                   , FromJSON t3
                   , FromJSON t2
                   , FromJSON t1
                   )
                => (t3 -> t5)
                -> (t1 -> t6)
                -> (t4 -> t7)
                -> (t2 -> t8)
                -> (t5 -> t6 -> b)
                -> (t7 -> t6 -> b)
                -> (t5 -> t8 -> b)
                -> (t7 -> t8 -> b)
                -> (t5 -> b)
                -> (t6 -> b)
                -> (t7 -> b)
                -> (t8 -> b)
                -> Parser b
                -> Object
                -> Parser b
parseRangeValue mkGt mkLt mkGte mkLte
                fGtLt fGteLt fGtLte fGteLte
                fGt fLt fGte fLte nada o = do
  lt <- o .:? "lt"
  lte <- o .:? "lte"
  gt <- o .:? "gt"
  gte <- o .:? "gte"
  case (lt, lte, gt, gte) of
    (Just a, _, Just b, _) ->
      return (fGtLt (mkGt b) (mkLt a))
    (Just a, _, _, Just b) ->
      return (fGteLt (mkGte b) (mkLt a))
    (_, Just a, Just b, _) ->
      return (fGtLte (mkGt b) (mkLte a))
    (_, Just a, _, Just b) ->
      return (fGteLte (mkGte b) (mkLte a))
    (_, _, Just a, _) ->
      return (fGt (mkGt a))
    (Just a, _, _, _) ->
      return (fLt (mkLt a))
    (_, _, _, Just a) ->
      return (fGte (mkGte a))
    (_, Just a, _, _) ->
      return (fLte (mkLte a))
    (Nothing, Nothing, Nothing, Nothing) ->
      nada
parseRangeValue mkGt mkLt mkGte mkLte
                fGtLt fGteLt fGtLte fGteLte
                fGt fLt fGte fLte nada o = do
  lt <- o .:? "lt"
  lte <- o .:? "lte"
  gt <- o .:? "gt"
  gte <- o .:? "gte"
  case (lt, lte, gt, gte) of
    (Just a, _, Just b, _) ->
      return (fGtLt (mkGt b) (mkLt a))
    (Just a, _, _, Just b) ->
      return (fGteLt (mkGte b) (mkLt a))
    (_, Just a, Just b, _) ->
      return (fGtLte (mkGt b) (mkLte a))
    (_, Just a, _, Just b) ->
      return (fGteLte (mkGte b) (mkLte a))
    (_, _, Just a, _) ->
      return (fGt (mkGt a))
    (Just a, _, _, _) ->
      return (fLt (mkLt a))
    (_, _, _, Just a) ->
      return (fGte (mkGte a))
    (_, Just a, _, _) ->
      return (fLte (mkLte a))
    (Nothing, Nothing, Nothing, Nothing) ->
      nada