-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHask.hs
45 lines (32 loc) · 1.15 KB
/
Hask.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Categorifier.Test.Hask
( Hask (..),
)
where
import Categorifier.Category (ReferenceCat (..), RepCat (..), UnsafeCoerceCat (..))
import qualified Categorifier.Client as Client
import qualified Control.Arrow as Base
import qualified Control.Category as Base
-- | A trivial wrapper around __Hask__ for testing purposes.
data Hask a b = Hask {runHask :: a -> b}
{-# ANN Hask "Hlint: ignore Use newtype instead of data" #-}
instance Base.Category Hask where
id = Hask Base.id
Hask f . Hask g = Hask (f Base.. g)
instance Base.Arrow Hask where
arr = Hask
first (Hask f) = Hask (Base.first f)
instance Base.ArrowApply Hask where
app = Hask (Base.app . Base.first runHask)
instance Base.ArrowChoice Hask where
Hask f +++ Hask g = Hask (f Base.+++ g)
instance Base.ArrowLoop Hask where
loop (Hask f) = Hask (Base.loop f)
instance (Client.HasRep a, r ~ Client.Rep a) => RepCat Hask a r where
abstC = Hask Client.abst
reprC = Hask Client.repr
instance ReferenceCat Hask a b
instance UnsafeCoerceCat Hask a b where
unsafeCoerceK = Hask unsafeCoerceK