concept computation in category idris

appears as: computation, computations
Type-Driven Development with Idris

This is an excerpt from Manning's book Type-Driven Development with Idris.

In the type-driven development process, we often think about functions in terms of transformations between data types. As such, we often define intermediate types, such as Format in this section, to describe intermediate stages of a computation. There are two main reasons for doing this:

  • If the result is Just x, pass x to the rest of the computation.
  • Type, refine—The type of the ?Functor_rhs_1 hole tells you that x is a stateful computation:
      stateType : Type
      b : Type
      a : Type
      func : a -> b
      x : State stateType a
    --------------------------------------
    Functor_rhs_1 : State stateType b
    You can continue the definition by extracting the value from the computation x using Bind:
    Functor (State stateType) where
        map func x = Bind x (\val => ?Functor_rhs_1)