In a category with an initial object, AFAIK it’s standard to encode constants as morphisms from the initial object.

Sorry, of course I meant terminal object (1 or Unit).

]]>

-- Primitives Prim ∷ Prim (a → b) → (a ↣ b) Const ∷ Prim b → (a ↣ b)

I’m not happy with the similarity of Prim and Const. Perhaps there’s a simpler formulation.

Wouldn’t you want to model `Const b`

as a primitive `p`

of type `Unit → b`

, and then construct `Prim p`

of type `Unit ↣ b`

? In a category with an initial object, AFAIK it’s standard to encode constants as morphisms from the initial object.

The polymorphic `a`

in `Const`

result type seems especially unfortunate, since you can inadvertently pass whatever argument (you will likely still get some error, but probably not the best one).

I see you’re sharing `Prim`

with Haskell code, so those constants should also be encoded without the `Unit →`

part of the type in some places. Unfortunately I don’t see a perfect solution to that: it might be best to have a different type of primitives for CCCs, with a constructor for function primitives and one for constants which adds the `Unit →`

part, because that at least keeps the CCC language precisely matching its spec.

(Sorry for my bad quoting, I can’t find how to format comments properly, so I just tried out some Markdown dialect which kind-of-works).

]]>

apply ∘ (curry (apply ∘ (apply ∘ (const (,) △ (id ∘ exr) ∘ exr) △ (id ∘ exl) ∘ exr)) △ id)

I was asking myself, what is the interpretation of ‘const’ and of ‘(,)’ in the CCC?

The only answer I came up with that seemed to make sense was that const is the function

const :: (1 ↣ b) → (a ↣ b) const e = e ∘ it

where ‘it’ is the unique CCC morphism a ↣ 1, 1 being Unit; and ‘(,)’ means the CCC morphism

(,) :: 1 ↣ (a ⇨ (b ⇨ a × b)) (,) = curry (curry (exr ∘ exl △ exr))

I was curious why your ‘↣’ type representing the CCC morphisms didn’t have a fundamental constructor

It :: a ↣ Unit

corresponding to ‘it’, given that a terminal object 1 (or Unit) is required? I guess you can use Const as a generalization of that, but it seems to go somewhat outside of the category language…

]]>