CurryInfo: stylechecker-2.0.0 / Check.AST.Indent.Deriving.checkDerivingC

definition: Info
 
checkDerivingC :: SpanInfo -> [ConstrDecl] -> [QualIdent]-> CSM ()
checkDerivingC si cons derivs@(deriv:_) = case si of
  (SpanInfo (Span (Position ls cs) (Position le ce)) ks) -> do
    let derivSpan = (ks !! ((length cons) + 1))
        firstKeySpan = (ks !! ((length cons) + 2))
    unless (ls == le) --one line
      (if ((getSpanCol (ks !! 1) == getSpanCol derivSpan) || (cs+2 == getSpanCol derivSpan)) -- alignment 'deriving'
        then
          (unless (le == getSpanLi derivSpan) --deriving one line
            (if (spanAlign (drop ((length cons) + 2) ks)) -- alignment symbols in deriving body
                then
                  (if (checkAlign getCol (getCol (getSpanInfo deriv)) derivs) -- aligment classes
                    then
                      -- indentation
                      (unless ((getSpanCol firstKeySpan == (getSpanCol derivSpan) + 2) || (getSpanLi firstKeySpan == getSpanLi derivSpan))
                                  (report (Message (Span (Position (getSpanLi derivSpan) (getSpanCol derivSpan)) (Position le ce))
                                            (colorizeKey "classes" <+> text "wrong indention")
                                            ( text "indent by 2 from"
                                            <+> colorizeKey "deriving"
                                            <+> text "write first class in same line as"
                                            <+> colorizeKey "deriving"
                                            )
                                    )
                            )
                      )
                    else
                      (report (Message (Span (Position (getSpanLi derivSpan) (getSpanCol derivSpan)) (Position le ce))
                                (colorizeKey "classes" <+> text "not aligned")
                                ( text "align derived"
                                <+> colorizeKey "classes"
                                )
                              )
                      )
                  )
                else
                  (report (Message (Span (Position (getSpanLi derivSpan) (getSpanCol derivSpan)) (Position le ce))
                            (colorizeKey "symbols" <+> text "in deriving body not aligned")
                            ( text "align"
                            <+> colorizeKey "("
                            <+> text ","
                            <+> colorizeKey ")"
                            <+> text "and"
                            <+> colorizeKey ","
                            )
                          )
                  )
            )
          )
        else
          (report (Message (Span (Position ls cs) (Position le ce))
                                  (colorizeKey "deriving" <+> text "wrong formatting")
                                  ( text "align"
                                  <+> colorizeKey "deriving"
                                  <+> text "with"
                                  <+> colorizeKey "="
                                  <+> text "or indent by 2 from"
                                  <+> colorizeKey "data"
                                  )
                  )
          )
      )
  _ -> return ()
checkDerivingC _ _ [] = return ()
demand: Info
 argument 3
deterministic: Info
 deterministic operation
documentation: Info
 
Checks formatting.
failfree: Info
 <FAILING>
indeterministic: Info
 referentially transparent operation
infix: Info
 no fixity defined
iotype: Info
 {({SpanInfo},_,{:}) |-> _ || ({NoSpanInfo},_,{:}) |-> _ || (_,_,{[]}) |-> _}
name: Info
 checkDerivingC
precedence: Info
 no precedence defined
result-values: Info
 _
signature: Info
 Curry.SpanInfo.SpanInfo -> [Curry.Types.ConstrDecl] -> [Curry.Ident.QualIdent]
-> Control.Monad.Trans.State.StateT Types.CheckState Data.Functor.Identity.Identity ()
solution-complete: Info
 operation might suspend on free variables
terminating: Info
 possibly non-terminating
totally-defined: Info
 possibly non-reducible on same data term