1 {-# LANGUAGE DefaultSignatures #-}
2 {-# LANGUAGE NoImplicitPrelude #-}
3 {-# OPTIONS_GHC -fno-warn-tabs #-}
5 module Hcompta.Expr.Maybe where
7 import Data.Maybe (Maybe(..))
8 import Control.Monad (Monad(..))
9 import Data.Function (($))
11 import Hcompta.Expr.Dup
13 -- * Class 'Expr_Maybe'
15 class Expr_Maybe repr where
20 -> repr ((->) (repr a) (repr b))
33 -> repr ((->) (repr a) (repr b))
42 nothing :: repr (Maybe a)
43 nothing = return Nothing
44 just :: repr a -> repr (Maybe a)
49 instance -- Expr_Maybe Dup
54 ) => Expr_Maybe (Dup r1 r2) where
55 may (m1 `Dup` m2) (n1 `Dup` n2) (r1_j `Dup` r2_j) =
56 may m1 n1 (return $ \r1_a -> do
59 dup1 $ j $ r1_a `Dup` return a)
61 may m2 n2 (return $ \r2_a -> do
64 dup2 $ j $ return a `Dup` r2_a)
65 nothing = nothing `Dup` nothing
66 just (a1 `Dup` a2) = just (a1 `Dup` a2)