Skip to content

Commit 31b1cf1

Browse files
author
Thomas Mahler
committed
simple interpretation without Hask
1 parent a46d394 commit 31b1cf1

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/CCC/Interpreter.hs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
--}
1616

1717
module CCC.Interpreter (interp) where
18-
19-
import CCC.Cat (Cartesian (fstC, sndC, dupC), Monoidal (parC),
20-
NumCat (addC, mulC, subC))
18+
2119
import CCC.CatExpr (CatExpr (..), scottBool)
22-
import CCC.Hask ()
20+
--import CCC.Cat
21+
--import CCC.Hask ()
2322

2423
interp :: CatExpr a b -> (a -> b)
2524
interp (Comp f g) = interp f . interp g
@@ -49,4 +48,25 @@ interp Gre = scottBool . uncurry (>)
4948
-- Fixpoint: step function is a CatExpr morphism, recursion stays categorical
5049
interp (Fix step) = \a ->
5150
let rec = Fix step
52-
in interp step (rec, a)
51+
in interp step (rec, a)
52+
53+
parC :: (a -> b) -> (c -> d) -> ((a, c) -> (b, d))
54+
parC f g (a, c) = (f a, g c)
55+
56+
fstC :: (a, b) -> a
57+
fstC (a, _b) = a
58+
59+
sndC :: (a, b) -> b
60+
sndC (_a, b) = b
61+
62+
dupC :: a -> (a, a)
63+
dupC a = (a, a)
64+
65+
addC :: (Num a) => (a, a) -> a
66+
addC (x, y) = x + y
67+
68+
subC :: (Num a) => (a, a) -> a
69+
subC (x, y) = x - y
70+
71+
mulC :: (Num a) => (a, a) -> a
72+
mulC (x, y) = x * y

0 commit comments

Comments
 (0)