-- SPDX-FileCopyrightText: 2020 Tocqueville Group
--
-- SPDX-License-Identifier: LicenseRef-MIT-TQ

{-# OPTIONS_GHC -Wno-orphans #-}

module Lorentz.UStore.Instances () where

import Lorentz.StoreClass
import Lorentz.UStore.Instr
import Lorentz.UStore.Types

instance HasUField fname ftype templ =>
         StoreHasField (UStore templ) fname ftype where
  storeFieldOps :: StoreFieldOps (UStore templ) fname ftype
storeFieldOps = $WStoreFieldOps :: forall store (fname :: Symbol) ftype.
(forall (s :: [*]). Label fname -> (store : s) :-> (ftype : s))
-> (forall (s :: [*]).
    Label fname -> (ftype : store : s) :-> (store : s))
-> StoreFieldOps store fname ftype
StoreFieldOps
    { sopToField :: forall (s :: [*]).
Label fname -> (UStore templ : s) :-> (ftype : s)
sopToField = forall (s :: [*]).
Label fname -> (UStore templ : s) :-> (ftype : s)
forall store (name :: Symbol) (s :: [*]).
FieldAccessC store name =>
Label name
-> (UStore store : s) :-> (GetUStoreField store name : s)
ustoreToField
    , sopSetField :: forall (s :: [*]).
Label fname -> (ftype : UStore templ : s) :-> (UStore templ : s)
sopSetField = forall (s :: [*]).
Label fname -> (ftype : UStore templ : s) :-> (UStore templ : s)
forall store (name :: Symbol) (s :: [*]).
FieldAccessC store name =>
Label name
-> (GetUStoreField store name : UStore store : s)
   :-> (UStore store : s)
ustoreSetField
    }

instance HasUStore mname key value templ =>
         StoreHasSubmap (UStore templ) mname key value where
  storeSubmapOps :: StoreSubmapOps (UStore templ) mname key value
storeSubmapOps = $WStoreSubmapOps :: forall store (mname :: Symbol) key value.
(forall (s :: [*]).
 Label mname -> (key : store : s) :-> (Bool : s))
-> (forall (s :: [*]).
    KnownValue value =>
    Label mname -> (key : store : s) :-> (Maybe value : s))
-> (forall (s :: [*]).
    Label mname -> (key : Maybe value : store : s) :-> (store : s))
-> (forall (s :: [*]).
    Maybe (Label mname -> (key : store : s) :-> (store : s)))
-> (forall (s :: [*]).
    Maybe (Label mname -> (key : value : store : s) :-> (store : s)))
-> StoreSubmapOps store mname key value
StoreSubmapOps
    { sopMem :: forall (s :: [*]).
Label mname -> (key : UStore templ : s) :-> (Bool : s)
sopMem = forall (s :: [*]).
Label mname -> (key : UStore templ : s) :-> (Bool : s)
forall store (name :: Symbol) (s :: [*]).
KeyAccessC store name =>
Label name
-> (GetUStoreKey store name : UStore store : s) :-> (Bool : s)
ustoreMem
    , sopGet :: forall (s :: [*]).
KnownValue value =>
Label mname -> (key : UStore templ : s) :-> (Maybe value : s)
sopGet = forall (s :: [*]).
KnownValue value =>
Label mname -> (key : UStore templ : s) :-> (Maybe value : s)
forall store (name :: Symbol) (s :: [*]).
(KeyAccessC store name, ValueAccessC store name) =>
Label name
-> (GetUStoreKey store name : UStore store : s)
   :-> (Maybe (GetUStoreValue store name) : s)
ustoreGet
    , sopUpdate :: forall (s :: [*]).
Label mname
-> (key : Maybe value : UStore templ : s) :-> (UStore templ : s)
sopUpdate = forall (s :: [*]).
Label mname
-> (key : Maybe value : UStore templ : s) :-> (UStore templ : s)
forall store (name :: Symbol) (s :: [*]).
(KeyAccessC store name, ValueAccessC store name) =>
Label name
-> (GetUStoreKey store name
      : Maybe (GetUStoreValue store name) : UStore store : s)
   :-> (UStore store : s)
ustoreUpdate
    , sopDelete :: forall (s :: [*]).
Maybe
  (Label mname -> (key : UStore templ : s) :-> (UStore templ : s))
sopDelete = (Label mname -> (key : UStore templ : s) :-> (UStore templ : s))
-> Maybe
     (Label mname -> (key : UStore templ : s) :-> (UStore templ : s))
forall a. a -> Maybe a
Just Label mname -> (key : UStore templ : s) :-> (UStore templ : s)
forall store (name :: Symbol) (s :: [*]).
KeyAccessC store name =>
Label name
-> (GetUStoreKey store name : UStore store : s)
   :-> (UStore store : s)
ustoreDelete
    , sopInsert :: forall (s :: [*]).
Maybe
  (Label mname
   -> (key : value : UStore templ : s) :-> (UStore templ : s))
sopInsert = (Label mname
 -> (key : value : UStore templ : s) :-> (UStore templ : s))
-> Maybe
     (Label mname
      -> (key : value : UStore templ : s) :-> (UStore templ : s))
forall a. a -> Maybe a
Just Label mname
-> (key : value : UStore templ : s) :-> (UStore templ : s)
forall store (name :: Symbol) (s :: [*]).
(KeyAccessC store name, ValueAccessC store name) =>
Label name
-> (GetUStoreKey store name
      : GetUStoreValue store name : UStore store : s)
   :-> (UStore store : s)
ustoreInsert
    }