mirror of
https://github.com/github/semantic.git
synced 2024-12-19 12:51:52 +03:00
Merge pull request #2508 from github/more-flags
Use a Data.Flag rather than a Bool for force-indexing checks.
This commit is contained in:
commit
74bb7102fb
@ -1,4 +1,4 @@
|
|||||||
{-# LANGUAGE RankNTypes, KindSignatures #-}
|
{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving, RankNTypes, KindSignatures #-}
|
||||||
|
|
||||||
-- | -- This technique is due to Oleg Grenrus: <http://oleg.fi/gists/posts/2019-03-21-flag.html>
|
-- | -- This technique is due to Oleg Grenrus: <http://oleg.fi/gists/posts/2019-03-21-flag.html>
|
||||||
-- The implementation is clean-room due to unclear licensing of the original post.
|
-- The implementation is clean-room due to unclear licensing of the original post.
|
||||||
@ -10,7 +10,7 @@ module Data.Flag
|
|||||||
, choose
|
, choose
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Coerce
|
import Prologue
|
||||||
|
|
||||||
-- | To declare a new flag, declare a singly-inhabited type:
|
-- | To declare a new flag, declare a singly-inhabited type:
|
||||||
-- @data MyFlag = MyFlag@
|
-- @data MyFlag = MyFlag@
|
||||||
@ -19,6 +19,8 @@ import Data.Coerce
|
|||||||
-- working with multiple flag values in flight, as the 'toBool' deconstructor provides a witness
|
-- working with multiple flag values in flight, as the 'toBool' deconstructor provides a witness
|
||||||
-- that you really want the given semantic flag value from the flag datum.
|
-- that you really want the given semantic flag value from the flag datum.
|
||||||
newtype Flag (t :: *) = Flag Bool
|
newtype Flag (t :: *) = Flag Bool
|
||||||
|
deriving stock (Eq, Show)
|
||||||
|
deriving newtype NFData
|
||||||
|
|
||||||
-- | The constructor for a 'Flag'. You specify @t@ with a visible type application.
|
-- | The constructor for a 'Flag'. You specify @t@ with a visible type application.
|
||||||
flag :: t -> Bool -> Flag t
|
flag :: t -> Bool -> Flag t
|
||||||
|
Loading…
Reference in New Issue
Block a user