{-# OPTIONS_GHC -fno-warn-orphans #-}

module Data.NonNull.Instances
  (
  ) where

import ClassyPrelude

import Data.Aeson


instance ToJSON a => ToJSON (NonNull a) where
  toJSON = toJSON . toNullable

instance (FromJSON a, MonoFoldable a) => FromJSON (NonNull a) where
  parseJSON = parseJSON >=> maybe (fail "Expected non-empty structure") return . fromNullable


instance Hashable a => Hashable (NonNull a) where
  hashWithSalt s = hashWithSalt s . toNullable
