{-# LANGUAGE OverloadedStrings #-}

module Funcons.Core.Values.Composite.MapsBuiltin where

import Control.Applicative ((<$>))

import Funcons.EDSL hiding (map_)
import Funcons.MSOS (rewrittens)
import Funcons.Core.Values.Primitive.BoolBuiltin
import Funcons.Core.Values.Composite.SetsBuiltin

import qualified Funcons.Operations as VAL

import qualified Data.Set as S
import qualified Data.Map as M

import Data.Foldable (foldrM)

library :: FunconLibrary
library = [(Name, EvalFunction)] -> FunconLibrary
libFromList [
    (Name
"map-empty", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromNullaryValOp [Funcons] -> Funcons
map_empty_ [OpExpr Funcons] -> OpExpr Funcons
forall t. HasValues t => [OpExpr t] -> OpExpr t
VAL.map_empty_)
  , (Name
"is-map-empty", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
is_map_empty_ [OpExpr Funcons] -> OpExpr Funcons
forall t. HasValues t => [OpExpr t] -> OpExpr t
VAL.is_map_empty_)
  , (Name
"map-insert", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
map_insert_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (HasValues t, Ord t) => [OpExpr t] -> OpExpr t
VAL.map_insert_)
  , (Name
"map-lookup", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromSeqValOp [Funcons] -> Funcons
map_lookup_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (HasValues t, Ord t) => [OpExpr t] -> OpExpr t
VAL.map_lookup_)
  , (Name
"lookup", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromSeqValOp [Funcons] -> Funcons
map_lookup_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (HasValues t, Ord t) => [OpExpr t] -> OpExpr t
VAL.map_lookup_)
  , (Name
"map-domain", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
map_domain_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (HasValues t, Ord t) => [OpExpr t] -> OpExpr t
VAL.domain_)
  , (Name
"domain", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
map_domain_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (HasValues t, Ord t) => [OpExpr t] -> OpExpr t
VAL.domain_)
  , (Name
"dom", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
map_domain_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (HasValues t, Ord t) => [OpExpr t] -> OpExpr t
VAL.domain_)
  , (Name
"map-delete", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
map_delete_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (HasValues t, Ord t) => [OpExpr t] -> OpExpr t
VAL.map_delete_)
  , (Name
"is-in-domain", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
is_in_domain_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (Ord t, HasValues t) => [OpExpr t] -> OpExpr t
VAL.is_in_domain_)
  , (Name
"map-unite", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
map_unite_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (HasValues t, Ord t) => [OpExpr t] -> OpExpr t
VAL.map_unite_)
  , (Name
"map-override", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
map_override_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (HasValues t, Ord t) => [OpExpr t] -> OpExpr t
VAL.map_override_)
  , (Name
"maps", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
maps_ [OpExpr Funcons] -> OpExpr Funcons
forall t. HasValues t => [OpExpr t] -> OpExpr t
VAL.maps_)
  , (Name
"map", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromValOp [Funcons] -> Funcons
map_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (Ord t, HasValues t) => [OpExpr t] -> OpExpr t
VAL.map_)
  , (Name
"map-elements", ([Funcons] -> Funcons)
-> ([OpExpr Funcons] -> OpExpr Funcons) -> EvalFunction
fromSeqValOp [Funcons] -> Funcons
map_elements_ [OpExpr Funcons] -> OpExpr Funcons
forall t. (Ord t, HasValues t) => [OpExpr t] -> OpExpr t
VAL.map_elements_)
  ]  

map_ :: [Funcons] -> Funcons
map_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"map"
maps_ :: [Funcons] -> Funcons
maps_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"maps"
map_empty_ :: [Funcons] -> Funcons
map_empty_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"map-empty"
is_map_empty_ :: [Funcons] -> Funcons
is_map_empty_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"is-map-empty"
is_in_domain_ :: [Funcons] -> Funcons
is_in_domain_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"is-in-domain"
map_insert_ :: [Funcons] -> Funcons
map_insert_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"map-insert"
map_delete_ :: [Funcons] -> Funcons
map_delete_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"map-delete"
-- |
-- Computes the union over a sequence of maps.
-- If the maps do not have disjoint domains a failure signal is raised.
map_unite_ :: [Funcons] -> Funcons
map_unite_ = Name -> [Funcons] -> Funcons
FApp Name
"map-unite"
lookup_ :: [Funcons] -> Funcons
lookup_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"lookup"
map_lookup_ :: [Funcons] -> Funcons
map_lookup_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"lookup"
map_override_ :: [Funcons] -> Funcons
map_override_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"map-override"
domain_ :: [Funcons] -> Funcons
domain_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"domain"
dom_ :: [Funcons] -> Funcons
dom_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"domain"
map_domain_ :: [Funcons] -> Funcons
map_domain_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"domain"
map_elements_ :: [Funcons] -> Funcons
map_elements_ = Name -> [Funcons] -> Funcons
applyFuncon Name
"map-elements"