{-# OPTIONS_HADDOCK prune #-}
module ForSyDe.Atom.ExB.Absent (
AbstExt(..),
module ForSyDe.Atom.ExB
) where
import ForSyDe.Atom.ExB
import Prelude hiding (filter)
data AbstExt a = Abst
| Prst a
deriving (AbstExt a -> AbstExt a -> Bool
(AbstExt a -> AbstExt a -> Bool)
-> (AbstExt a -> AbstExt a -> Bool) -> Eq (AbstExt a)
forall a. Eq a => AbstExt a -> AbstExt a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbstExt a -> AbstExt a -> Bool
$c/= :: forall a. Eq a => AbstExt a -> AbstExt a -> Bool
== :: AbstExt a -> AbstExt a -> Bool
$c== :: forall a. Eq a => AbstExt a -> AbstExt a -> Bool
Eq)
instance ExB AbstExt where
extend :: a -> AbstExt a
extend = a -> AbstExt a
forall a. a -> AbstExt a
Prst
/.\ :: (a -> a') -> AbstExt a -> AbstExt a'
(/.\) = (a -> a') -> AbstExt a -> AbstExt a'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
/*\ :: AbstExt (a -> a') -> AbstExt a -> AbstExt a'
(/*\) = AbstExt (a -> a') -> AbstExt a -> AbstExt a'
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
(<*>)
(Prst True) /&\ :: AbstExt Bool -> AbstExt a -> AbstExt a
/&\ a :: AbstExt a
a = AbstExt a
a
_ /&\ _ = AbstExt a
forall a. AbstExt a
Abst
_ /!\ :: a -> AbstExt a -> a
/!\ Prst a :: a
a = a
a
a :: a
a /!\ _ = a
a
instance Show a => Show (AbstExt a) where
showsPrec :: Int -> AbstExt a -> ShowS
showsPrec _ x :: AbstExt a
x = AbstExt a -> ShowS
forall a. Show a => AbstExt a -> ShowS
showsPrst AbstExt a
x
where showsPrst :: AbstExt a -> ShowS
showsPrst Abst = String -> ShowS
forall a. [a] -> [a] -> [a]
(++) "\10178"
showsPrst (Prst x :: a
x) = String -> ShowS
forall a. [a] -> [a] -> [a]
(++) (a -> String
forall a. Show a => a -> String
show a
x)
instance Read a => Read (AbstExt a) where
readsPrec :: Int -> ReadS (AbstExt a)
readsPrec _ x :: String
x = ReadS (AbstExt a)
forall a. Read a => String -> [(AbstExt a, String)]
readsAbstExt String
x
where
readsAbstExt :: String -> [(AbstExt a, String)]
readsAbstExt s :: String
s =
[(AbstExt a
forall a. AbstExt a
Abst, String
r1) | ("_", r1 :: String
r1) <- ReadS String
lex String
s] [(AbstExt a, String)]
-> [(AbstExt a, String)] -> [(AbstExt a, String)]
forall a. [a] -> [a] -> [a]
++
[(a -> AbstExt a
forall a. a -> AbstExt a
Prst a
x, String
r3) | (x :: a
x, r3 :: String
r3) <- ReadS a
forall a. Read a => ReadS a
reads String
s]
instance Functor AbstExt where
fmap :: (a -> b) -> AbstExt a -> AbstExt b
fmap _ Abst = AbstExt b
forall a. AbstExt a
Abst
fmap f :: a -> b
f (Prst x :: a
x) = b -> AbstExt b
forall a. a -> AbstExt a
Prst (a -> b
f a
x)
instance Applicative AbstExt where
pure :: a -> AbstExt a
pure = a -> AbstExt a
forall a. a -> AbstExt a
Prst
(Prst x :: a -> b
x) <*> :: AbstExt (a -> b) -> AbstExt a -> AbstExt b
<*> (Prst y :: a
y) = b -> AbstExt b
forall a. a -> AbstExt a
Prst (a -> b
x a
y)
Abst <*> Abst = AbstExt b
forall a. AbstExt a
Abst
_ <*> _ = String -> AbstExt b
forall a. HasCallStack => String -> a
error "[ExB.Absent] Illegal occurrence of an absent and present event"