1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +03:00

Define a Boolean effect.

This commit is contained in:
Rob Rix 2018-08-23 11:13:31 -04:00
parent cfdc8030b1
commit 956d572ace

View File

@ -1,4 +1,4 @@
{-# LANGUAGE GADTs, Rank2Types #-}
{-# LANGUAGE GADTs, KindSignatures, Rank2Types #-}
module Control.Abstract.Value
( AbstractValue(..)
, AbstractIntro(..)
@ -73,6 +73,16 @@ instance PureEffect (Function address value) where
handle handler (Request (Call fn self addrs) k) = Request (Call fn self addrs) (handler . k)
data Boolean value (m :: * -> *) result where
Boolean :: Bool -> Boolean value m value
AsBool :: value -> Boolean value m Bool
instance PureEffect (Boolean value)
instance Effect (Boolean value) where
handleState state handler (Request (Boolean b) k) = Request (Boolean b) (handler . (<$ state) . k)
handleState state handler (Request (AsBool v) k) = Request (AsBool v) (handler . (<$ state) . k)
class Show value => AbstractIntro value where
-- | Construct an abstract unit value.
-- TODO: This might be the same as the empty tuple for some value types