exprInfoFromPl ::
    Monad i =>
    GuiM env i o
    (Sugar.Payload v o0 -> ExprInfo o0)
exprInfoFromPl =
    GuiState.isSubCursor <&>
    \isSubCursor pl ->
    let isSelected = WidgetIds.fromExprPayload pl & isSubCursor in
    ExprInfo
    { exprInfoActions = pl ^. Sugar.plActions
    , exprInfoMinOpPrec =
        -- Expression with parentheses intercepts all operations from inside it,
        -- But if it is itself selected then we're out of the parentheses,
        -- and its parents may take some operators.
        if pl ^. Sugar.plParenInfo . Sugar.piNeedParens && not isSelected
        then 0
        else pl ^. Sugar.plParenInfo . Sugar.piMinOpPrec
    , exprInfoIsSelected = isSelected
    }
exprInfoFromPl ::
    Monad i =>
    GuiM env i o
    (Sugar.Payload v o0 -> ExprInfo o0)
exprInfoFromPl =
    GuiState.isSubCursor <&>
    \isSubCursor pl ->
    let isSelected = WidgetIds.fromExprPayload pl & isSubCursor in
    ExprInfo
    { exprInfoActions = pl ^. Sugar.plActions
    , exprInfoMinOpPrec =
        -- Expression with parentheses intercepts all operations from inside it,
        -- But if it is itself selected then we're out of the parentheses,
        -- and its parents may take some operators.
        if pl ^. Sugar.plParenInfo . Sugar.piNeedParens && not isSelected
        then 0
        else pl ^. Sugar.plParenInfo . Sugar.piMinOpPrec
    , exprInfoIsSelected = isSelected
    }
exprInfoFromPl =
    GuiState.isSubCursor <&>
    \isSubCursor pl ->
    let isSelected = WidgetIds.fromExprPayload pl & isSubCursor in
    ExprInfo
    { exprInfoActions = pl ^. Sugar.plActions
    , exprInfoMinOpPrec =
        -- Expression with parentheses intercepts all operations from inside it,
        -- But if it is itself selected then we're out of the parentheses,
        -- and its parents may take some operators.
        if pl ^. Sugar.plParenInfo . Sugar.piNeedParens && not isSelected
        then 0
        else pl ^. Sugar.plParenInfo . Sugar.piMinOpPrec
    , exprInfoIsSelected = isSelected
    }