never executed always true always false
    1 module ElmFormat.KnownContents
    2     ( KnownContents
    3     , fromFunction
    4     , isKnown, get
    5     )
    6     where
    7 
    8 import AST.V0_16
    9 
   10 newtype KnownContents =
   11     KnownContents ([UppercaseIdentifier] -> Maybe [LocalName]) -- return Nothing if the contents are unknown
   12 
   13 instance Semigroup KnownContents where
   14     (KnownContents a) <> (KnownContents b) = KnownContents (\ns -> a ns <> b ns)
   15 
   16 instance Monoid KnownContents where
   17     mempty = fromFunction (const Nothing)
   18 
   19 
   20 fromFunction :: ([UppercaseIdentifier] -> Maybe [LocalName]) -> KnownContents
   21 {-# INLINE fromFunction #-}
   22 fromFunction = KnownContents
   23 
   24 
   25 isKnown :: KnownContents -> [UppercaseIdentifier] -> Bool
   26 isKnown (KnownContents lookup) =
   27     maybe False (const True) . lookup
   28 
   29 
   30 get :: [UppercaseIdentifier] -> KnownContents -> Maybe [LocalName]
   31 {-# INLINE get #-}
   32 get ns (KnownContents lookup) =
   33     lookup ns