{-# LANGUAGE TemplateHaskell #-}

module Swarm.Language.Typed (Typed (..), value, polytype, requires) where

import Control.Lens (makeLenses)
import Data.Aeson (ToJSON)
import Data.Aeson.Types (FromJSON)
import GHC.Generics (Generic)
import Swarm.Language.Requirement (Requirements)
import Swarm.Language.Types (Polytype)

-- | A value, or a hole, or something else that has its type & requirements fixed
data Typed v = Typed
  { forall v. Typed v -> v
_value :: v
  , forall v. Typed v -> Polytype
_polytype :: Polytype
  , forall v. Typed v -> Requirements
_requires :: Requirements
  }
  deriving (Int -> Typed v -> ShowS
forall v. Show v => Int -> Typed v -> ShowS
forall v. Show v => [Typed v] -> ShowS
forall v. Show v => Typed v -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Typed v] -> ShowS
$cshowList :: forall v. Show v => [Typed v] -> ShowS
show :: Typed v -> String
$cshow :: forall v. Show v => Typed v -> String
showsPrec :: Int -> Typed v -> ShowS
$cshowsPrec :: forall v. Show v => Int -> Typed v -> ShowS
Show, Typed v -> Typed v -> Bool
forall v. Eq v => Typed v -> Typed v -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Typed v -> Typed v -> Bool
$c/= :: forall v. Eq v => Typed v -> Typed v -> Bool
== :: Typed v -> Typed v -> Bool
$c== :: forall v. Eq v => Typed v -> Typed v -> Bool
Eq, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall v x. Rep (Typed v) x -> Typed v
forall v x. Typed v -> Rep (Typed v) x
$cto :: forall v x. Rep (Typed v) x -> Typed v
$cfrom :: forall v x. Typed v -> Rep (Typed v) x
Generic, forall v. FromJSON v => Value -> Parser [Typed v]
forall v. FromJSON v => Value -> Parser (Typed v)
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Typed v]
$cparseJSONList :: forall v. FromJSON v => Value -> Parser [Typed v]
parseJSON :: Value -> Parser (Typed v)
$cparseJSON :: forall v. FromJSON v => Value -> Parser (Typed v)
FromJSON, forall v. ToJSON v => [Typed v] -> Encoding
forall v. ToJSON v => [Typed v] -> Value
forall v. ToJSON v => Typed v -> Encoding
forall v. ToJSON v => Typed v -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Typed v] -> Encoding
$ctoEncodingList :: forall v. ToJSON v => [Typed v] -> Encoding
toJSONList :: [Typed v] -> Value
$ctoJSONList :: forall v. ToJSON v => [Typed v] -> Value
toEncoding :: Typed v -> Encoding
$ctoEncoding :: forall v. ToJSON v => Typed v -> Encoding
toJSON :: Typed v -> Value
$ctoJSON :: forall v. ToJSON v => Typed v -> Value
ToJSON)

makeLenses ''Typed