visio光学器件怎么画

    科技2026-08-05  5

    visio光学器件怎么画

    I want to chime in on the sleeping Giant that are Lenses and Prisms in software development:

    我想介绍一下沉睡中的巨人,他们是软件开发中的镜头和棱镜:

    They are probably the most powerful unused tool in our arsenal!

    它们可能是我们武器库中最强大的未使用工具!

    作为学习工具 (As a Learning Tool)

    Optics can be the perfect bridge from Algebraic Data Types to the Functor hierarchies and beyond. They can the prism (could not resist the pun) through which you can peek into useful and concrete applications of more abstract ideas; once you understand the connection between:

    光学可以是从代数数据类型到Functor层次结构以及其他功能的完美桥梁。 它们可以作为棱镜(无法抗拒双关语),您可以通过它窥视更抽象的思想的有用和具体的应用。 一旦了解了以下内容之间的联系:

    tuples and functions

    元组和功能 products and powers

    产品和权力 conjunction and implication

    连词和蕴涵

    Optics is a very concrete and visceral connection between computation and logic. The way I think of Optics is a portable way to house the logical connection between two types.

    光学是计算与逻辑之间非常具体且内在的联系。 我对光学的看法是一种可移植的方式来容纳两种类型之间的逻辑连接。

    We can ask ourselves how do we encode a biconditional(A→B ∧ B→A)? E.g. If I have 1 meter then I can get you 3.28084 feet, and if I have 1 feet then I can get you 0.3048 meters. There is a logic interpretation that says, if we have x meters than we can get y feet and vice-versa.

    我们可以问自己如何编码一个双条件(A→B∧B→A)? 例如,如果我有1米,那么我可以让你3.28084英尺,如果我有1英尺,那么我可以让你0.3048米。 有一种逻辑解释说,如果我们有x米,那么我们可以得到y英尺,反之亦然。

    As we grow comfortable with quick exercises around the consequences of these observations like bi-conditional above (A→B ∧ B→A) then it is a very short jump to again seeing it as just a tuple of functions, this all then helps to strengthen intuitions around existence as proof.

    随着我们对这些观察结果的快速练习感到满意,例如上述双条件(A→B∧B→A),那么再次将其视为功能元组就非常短,这一切都有助于加强关于存在的直觉作为证据。

    We can weaken the statement and say you can’t always go back from B to A; that you need some other A before the information in B can get you all the way around; that statement then is (A→B ∧ (A∧B→A)); and it may seem less useful in logic, but is actually yields very valid operation when exploring the problem from the computational angle. It is also an extremely useful example of highlighting the value of being able to shift back and forth between perspectives.

    我们可以削弱这一说法,说您不能总是从B回到A。 在B中的信息可以使您全面了解之前,您还需要其他A; 该语句为(A→B∧(A∧B→A)); 它在逻辑上似乎没什么用,但是当从计算角度探索问题时,实际上产生了非常有效的运算。 这也是突出显示能够在不同视角之间来回移动的价值的极为有用的示例。

    As you explore more general encodings they visit Predicate Functor Logic’s connection to type classes in Haskell and the notion of Context Bounds in Scala and again help developers find connections between internal computations and the unpredictable effects of interacting with the real world.

    当您探索更通用的编码时,它们会访问Predicate Functor Logic与Haskell中的类型类的连接以及Scala中的Context Bounds的概念,并再次帮助开发人员在内部计算与与现实世界交互的不可预测效果之间找到联系。

    Before that, you will notice a Traversal in optics goes from A to B, that is to say one A can go through many Bs… You can start describing your A as a basket with many apples and you can iterate over that basket, and take a bite out of every apple; but you have the concrete specific basket that is A. It is a smooth insertion point to say; well, we can also talk about a List of things, and you get to introduce the Traverse type class, and higher kinded types with enough of a base of concrete examples, you get the opportunity to go back and retrofit the basic optics implementation as profunctors.

    在此之前,您会发现光学的遍历从A到B,也就是说一个A可以穿过许多B。您可以开始将A描述为一个装有很多苹果的篮子,然后可以遍历该篮子并取走咬一口苹果 但是您有一个具体的具体篮子,即A。 好吧,我们也可以讨论事物列表,并且您可以介绍Traverse类型类,以及带有足够具体示例的更高种类的类型,您有机会回过头来完善基本的光学实现。

    Here is a Traversal from a BalanceSheet to every time inside every transaction:

    这是从BalanceSheet到每次事务内的每次遍历:

    Example of some small functions composing together 一些小的函数组成的例子

    It is a very elegant introduction to effects and encourages strong re-use; You are able to describe effectful functors, and aplicatives with a foggy glass metaphor that is susceptible to atmospheric conditions; and are then logical predicates that introduce uncertainty and undecidability to the original logical statements in your clear optics.

    这是对效果的非常优雅的介绍,并鼓励强烈重复使用; 您可以使用易受大气条件影响的有雾玻璃隐喻来描述有效的函子和增殖物; 然后是逻辑谓词,这些逻辑谓词会为清晰的光学系统中的原始逻辑语句带来不确定性和不确定性。

    Here a pure lens is combined with a database storage effect 在这里,纯净的镜头与数据库存储效果结合在一起

    模块化应用设计 (Modular Application Design)

    Because they are a concrete, portable way to relate two types; you can allow one type to vary and replace a direct dependence on a specific data type with an Optic, which can hold the relevant attributes about the required relationship. You are able, for example, to specify if you need the guarantees of an Iso, or the freedom of a Getter. This means interoperability between otherwise wholly independent modules is straight forward and can be done simply at the call site, or automated via some form of code generator in your host language.

    因为它们是联系两种类型的一种具体的,可移植的方式。 您可以允许一种类型进行更改,并用Optic替换对特定数据类型的直接依赖关系,该Optic可以保留有关所需关系的相关属性。 例如,您可以指定是否需要Iso的担保或Getter的自由。 这意味着原本完全独立的模块之间的互操作性很简单,可以在调用站点上简单地完成,也可以通过某种形式的代码生成器以您的宿主语言自动执行。

    We can eliminate the dependence on the BalanceSheet type by requiring a Traversal instead. 我们可以通过需要遍历来消除对BalanceSheet类型的依赖。

    Optics are also great at turning a host language’s control flow into just type definitions.

    光学还擅长将宿主语言的控制流转换为类型定义。

    What to do is decided by the effect type: IO, and the machinery of fs2 做什么由效果类型决定:IO和fs2的机制

    Leveraging optics helps make your code more reusable; in fact, the clarity of composition lets you write complex ETL or data transformation pipelines by simply composing different optics with the most basic set of actions you want to perform in whatever environmental context you are in.

    利用光学元件可以使您的代码更具可重用性。 实际上,清晰的结构使您可以通过简单地将不同的光学组件与要在任何环境环境中执行的最基本的动作组合在一起来编写复杂的ETL或数据转换管道。

    可重复使用的测试 (Re-usable tests)

    Re-using the existing code from any given Optics library, not only means there is less of your own code to maintain; but it also implies the burden of testing is greatly reduced as the combinators will be already tested in the library itself and you can re-use it’s existing tests on your own particularly defined instances.

    重用任何给定Optics库中的现有代码,不仅意味着您自己需要维护的代码更少; 但这还意味着测试的负担将大大减轻,因为组合器已经在库中进行了测试,并且您可以在自己定义的实例上重用它的现有测试。

    You can, for example, run all the tests for a valid traversal on your own custom ones. 例如,您可以在自己的自定义测试中运行所有测试以进行有效遍历。

    翻译自: https://medium.com/swlh/we-need-more-optics-8ddf1d2d9468

    visio光学器件怎么画

    相关资源:VISIO电子元件器件库.rar
    Processed: 0.009, SQL: 9