module GraphRewriting.Pattern.InteractionNet where
import Prelude.Unicode
import Data.View
import Data.Functor
import GraphRewriting.Graph.Types
import GraphRewriting.Pattern
class INet n where principalPort ∷ n → Port
data Pair a = a :-: a
instance Functor Pair where fmap f (x :-: y) = f x :-: f y
pair ∷ Pair a → (a,a)
pair (x :-: y) = (x,y)
activePair ∷ (View [Port] n, View v n, INet v) ⇒ Pattern n (Pair v)
activePair = linear $ do
v1 ← node
let pp1 = principalPort v1
v2 ← nodeWith pp1
require (pp1 ≡ principalPort v2)
return (v1 :-: v2)