Skip to content

Commit 0eb706a

Browse files
author
Thomas Mahler
committed
use more of Hask
1 parent a2be607 commit 0eb706a

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/CCC/Hask.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{-# OPTIONS_GHC -fno-warn-orphans #-}
22

3-
{-- | Instance-only module for interpreting categorical terms in the (->) category. --}
3+
{-- | Instance-only module for interpreting categorical terms in the (->) category.
4+
This module provides the necessary type class instances to treat Haskell functions
5+
as morphisms in the (->) category, allowing us to interpret CatExpr morphisms
6+
as actual Haskell functions without needing to define the logic of those functions ourselves.
7+
--}
48

59
module CCC.Hask () where
610

src/CCC/Interpreter.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
module CCC.Interpreter (interp) where
1212

1313
import CCC.Cat (BoolCat (andC, notC, orC),
14-
BoolLike (false, true), Cartesian (dupC),
14+
BoolLike (false, true), Cartesian (fstC, sndC, dupC),
1515
EqCat (eqlC), Monoidal (parC),
1616
NumCat (addC, geqC, greC, leqC, lesC, mulC, subC))
1717
import CCC.CatExpr (CatExpr (..))
18+
-- Hask is imported for its instance definitions, not for any specific functions or types
19+
-- This allows us to interpret CatExpr morphisms as actual Haskell functions without needing to
20+
--define the logic of those functions ourselves.
1821
import CCC.Hask ()
1922

2023
interp :: CatExpr a b -> (a -> b)
@@ -26,8 +29,8 @@ interp Apply = uncurry interp
2629
interp Id = id
2730
interp (IntConst i) = const i
2831
interp FromInt = fromInteger
29-
interp Fst = fst
30-
interp Snd = snd
32+
interp Fst = fstC
33+
interp Snd = sndC
3134
interp Dup = dupC
3235
interp Add = addC
3336
interp Sub = subC

0 commit comments

Comments
 (0)