Skip to content
Snippets Groups Projects
Commit af0126cf authored by Bodigrim's avatar Bodigrim Committed by Mikolaj
Browse files

Add instance Ord for Field, FieldLine, SectionArg and Name

parent 2fca50ba
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE StandaloneDeriving #-}
-- | Cabal-like file AST types: 'Field', 'Section' etc
--
......@@ -51,6 +52,9 @@ data Field ann
| Section !(Name ann) [SectionArg ann] [Field ann]
deriving (Eq, Show, Functor, Foldable, Traversable)
-- | @since 3.12.0.0
deriving instance Ord ann => Ord (Field ann)
-- | Section of field name
fieldName :: Field ann -> Name ann
fieldName (Field n _) = n
......@@ -73,6 +77,9 @@ fieldUniverse f@(Field _ _) = [f]
data FieldLine ann = FieldLine !ann !ByteString
deriving (Eq, Show, Functor, Foldable, Traversable)
-- | @since 3.12.0.0
deriving instance Ord ann => Ord (FieldLine ann)
-- | @since 3.0.0.0
fieldLineAnn :: FieldLine ann -> ann
fieldLineAnn (FieldLine ann _) = ann
......@@ -91,6 +98,9 @@ data SectionArg ann
SecArgOther !ann !ByteString
deriving (Eq, Show, Functor, Foldable, Traversable)
-- | @since 3.12.0.0
deriving instance Ord ann => Ord (SectionArg ann)
-- | Extract annotation from 'SectionArg'.
sectionArgAnn :: SectionArg ann -> ann
sectionArgAnn (SecArgName ann _) = ann
......@@ -109,6 +119,9 @@ type FieldName = ByteString
data Name ann = Name !ann !FieldName
deriving (Eq, Show, Functor, Foldable, Traversable)
-- | @since 3.12.0.0
deriving instance Ord ann => Ord (Name ann)
mkName :: ann -> FieldName -> Name ann
mkName ann bs = Name ann (B.map Char.toLower bs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment