[Matthew](https://forum.azimuthproject.org/profile/1818/Matthew%20Doty), after sleeping over my problem I think I've arrived at the solution of creating an intance of Interpret for the function (->) category which gets its Language instance from the general category one.

So, getting both `run` and `interpret`for the (->) instance [Tagless Puzzle 2](https://forum.azimuthproject.org/discussion/comment/16735/#Comment_16735), the code for (->) is simply:

{-# LANGUAGE Rank2Types #-}

module LanguageFun2 where

import CompilingToCategories

import Language

import LanguageCat

instance Interpreted (->) where

run f h = f h

interpret :: Term a -> a

interpret t = (run :: (h -> a) -> h -> a) t ()

I've tested over the same examples that worked over the direct implementation of `Language (->)` and these work:

interpret (apply (lambda here) (int 6))

interpret (apply (lambda here) (bool True))

interpret (ifte (bool True) (int 3) (int 4))

But I have problems with:

ex = lambda (lambda (add (before here) here))

I've needed to add FlexibleContexts because it complained with this:

• Non type-variable argument in the constraint: ConstCat k Bool

(Use FlexibleContexts to permit this)

• When checking the inferred type

ex :: forall h (k :: * -> * -> *).

(BoolCat k, ConstCat k Bool, ConstCat k Int, OrdCat k Int,

NumCat k Int, Closed k) =>

k h (Int -> Int -> Int)

and after adding it, the type I get is

ex :: (BoolCat k, ConstCat k Bool, ConstCat k Int, OrdCat k Int,

NumCat k Int, Closed k) =>k h (Int -> Int -> Int)

But now, when I try

interpret (apply (apply ex (int 3)) (int 2))

I get

• Could not deduce (BoolCat k) arising from a use of ‘ex’

from the context: Language k

bound by a type expected by the context:

Language k => k h Int

at:5:1-44

Possible fix:

add (BoolCat k) to the context of

a type expected by the context:

Language k => k h Int

• In the first argument of ‘apply’, namely ‘ex’

In the first argument of ‘apply’, namely ‘(apply ex (int 3))’

In the first argument of ‘interpret’, namely

‘(apply (apply ex (int 3)) (int 2))’

And this is all I have.

PS: The [`Monad Classical` Puzzle](https://forum.azimuthproject.org/discussion/comment/16975/#Comment_16975) will have to wait for now :-)

So, getting both `run` and `interpret`for the (->) instance [Tagless Puzzle 2](https://forum.azimuthproject.org/discussion/comment/16735/#Comment_16735), the code for (->) is simply:

{-# LANGUAGE Rank2Types #-}

module LanguageFun2 where

import CompilingToCategories

import Language

import LanguageCat

instance Interpreted (->) where

run f h = f h

interpret :: Term a -> a

interpret t = (run :: (h -> a) -> h -> a) t ()

I've tested over the same examples that worked over the direct implementation of `Language (->)` and these work:

interpret (apply (lambda here) (int 6))

interpret (apply (lambda here) (bool True))

interpret (ifte (bool True) (int 3) (int 4))

But I have problems with:

ex = lambda (lambda (add (before here) here))

I've needed to add FlexibleContexts because it complained with this:

• Non type-variable argument in the constraint: ConstCat k Bool

(Use FlexibleContexts to permit this)

• When checking the inferred type

ex :: forall h (k :: * -> * -> *).

(BoolCat k, ConstCat k Bool, ConstCat k Int, OrdCat k Int,

NumCat k Int, Closed k) =>

k h (Int -> Int -> Int)

and after adding it, the type I get is

ex :: (BoolCat k, ConstCat k Bool, ConstCat k Int, OrdCat k Int,

NumCat k Int, Closed k) =>k h (Int -> Int -> Int)

But now, when I try

interpret (apply (apply ex (int 3)) (int 2))

I get

• Could not deduce (BoolCat k) arising from a use of ‘ex’

from the context: Language k

bound by a type expected by the context:

Language k => k h Int

at

Possible fix:

add (BoolCat k) to the context of

a type expected by the context:

Language k => k h Int

• In the first argument of ‘apply’, namely ‘ex’

In the first argument of ‘apply’, namely ‘(apply ex (int 3))’

In the first argument of ‘interpret’, namely

‘(apply (apply ex (int 3)) (int 2))’

And this is all I have.

PS: The [`Monad Classical` Puzzle](https://forum.azimuthproject.org/discussion/comment/16975/#Comment_16975) will have to wait for now :-)