User Tools

Site Tools


codesnippets:codingconventions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

codesnippets:codingconventions [2024/06/02 22:00] – [~~DISCUSSION~~] f2b216codesnippets:codingconventions [2025/10/08 00:48] (current) – external edit 127.0.0.1
Line 228: Line 228:
   * [[codesnippets:codingconventions#ghc_extensions_and_options|GHC extensions and options]]   * [[codesnippets:codingconventions#ghc_extensions_and_options|GHC extensions and options]]
   * [[codesnippets:codingconventions#module_declaration_and_export_list|Module declaration and export list]]   * [[codesnippets:codingconventions#module_declaration_and_export_list|Module declaration and export list]]
 +    * keyword: module
   * [[codesnippets:codingconventions#sections|Sections]]   * [[codesnippets:codingconventions#sections|Sections]]
-  * [[codesnippets:codingconventions#class_declarations|Class declarations]] +  * [[codesnippets:codingconventions#class_declaration|Class declaration]] 
-  * [[codesnippets:codingconventions#data_type_declarations|Data type declarations]] +    * keyword: class 
-    *  (data, type, newtype) +  * [[codesnippets:codingconventions#data_type_declaration|Data type declaration]] 
-  * [[codesnippets:codingconventions#instance_declarations|Instance declarations]] +    *  keywords: data, type, newtype 
-  * [[codesnippets:codingconventions#function_declarations|Function declarations]]+  * [[codesnippets:codingconventions#instance_declaration|Instance declaration]] 
 +    * keyword: instance 
 +  * [[codesnippets:codingconventions#function_declaration|Function declaration]]
  
 ==== Module description ==== ==== Module description ====
Line 241: Line 244:
     * description (''Description'')     * description (''Description'')
       * in way that it becomes a complete sentence when started with module name       * in way that it becomes a complete sentence when started with module name
-        * like in the code below it translates to ''PrettyLines is to print to a line oriented output devices (e.g. stdout), in a pretty formatted way.'' +        * like in the code below it translates to ''HPowerLib.ExportTest makes it easier to export functional tests that are not exported themselves.'' 
-    * copright according to the example below+    * copyright according to the example below
     * license     * license
       * All rights reserved       * All rights reserved
Line 258: Line 261:
     * bullets     * bullets
       * most important properties       * most important properties
-      * example +    expandable example 
-      * output of example+      * may be with output of example 
 +      * ideally using doc test 
 +        * example: <code> 
 +-- >>> fact 5 
 +-- 120  
 +</code>
  
   * Example: <code Haskell>   * Example: <code Haskell>
 {-| {-|
-Description : is to print to a line oriented output devices (e.g. stdout), in a pretty formatted way.+Description : makes it easier to export functional tests that are not exported themselves.
 Copyright   : (c) Jörg K.-H. W. Brüggmann, 2021-2024 Copyright   : (c) Jörg K.-H. W. Brüggmann, 2021-2024
 License     : All rights reserved License     : All rights reserved
Line 270: Line 278:
 Portability : POSIX Portability : POSIX
  
-supports formatting by the following type class:+makes it easier to export functional tests that are not exported themselves.
  
-    Formatting+suggested prefix: __/Exp/__
  
-        * of types that can be converted into a string by using 'format' and 'print' it to IO ().+See also module HPowerLib.ImportTests, which supports import of the tests into the test framework Tasty.
  
-* implements the following instances of type classes Formatting:+==== __Example code to export tests__
  
-    * 'DataStruct.Tree' 
- 
-* example 
  
     @     @
-module Main where+...
  
-import qualified DataStruct as Dt +module HPowerLib.Parser 
-import qualified PrettyLines as PrtLns (Formatting(..)) +    ( 
- +        ... 
-main :: IO () +        , ..
-main = do +        , testGroup_parseComposable 
-    PrtLns.print $ myTree +    ) where
- +
-data Symbol = A | B | C +
-    deriving Show+
  
 ... ...
     @     @
- 
-* creates the following output to stdout 
- 
-    @ 
-    Ah 
-    +-Ah 
-    +-Beh 
-    | +-Ah 
-    | +-Beh 
-    | +-Ceh 
-    +-Ceh 
-    +-Ah 
-    @ 
- 
 -} -}
 </code> </code>
Line 458: Line 446:
  
   * example: <code Haskell>   * example: <code Haskell>
-class Show => Format d where +-- HUnit 
-    {- |  +-- | ...capability to compare the expected value with the actual one,  
-    * formated in a human readable pretty waywhen printed to a text file or stream like _stdout_.+-- |    and to display the difference if there is one. 
 +{-|  
 +-} 
 +class Show cmp ) => HUnit cmp where 
 +    -- equals 
 +    {- | ...compares the expected value with the actual one. 
 +    * result 'True' if both values are equalotherwise 'False'
     -}     -}
-    display  +    equals  
-        -- | data to be formated in a pretty way +        :: cmp      -- ^ actual value 
-        :: d +        -> cmp      -- ^ expected value 
-        -- | formatted string representing the data +        -> Bool     -- ^ 'True' when actual value and expected value is considered equal, otherwise 'False' 
-        -> String+
 </code> </code>
  
Line 647: Line 641:
 </code> </code>
  
-===== =====+ 
 +===== ✎ =====
 ~~DISCUSSION~~ ~~DISCUSSION~~
codesnippets/codingconventions.1717358459.txt.gz · Last modified: (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki