What means?

I am trying to learn Haskell.

I read the code here [1]. I just copy and go through part of the code from the lines: 46 and 298-300.

Question : What does (..) mean?

I missed this, but did not get a result.

module Pos.Core.Types(
-- something here

 SharedSeed (..) -- what does this mean?

) where


newtype SharedSeed = SharedSeed
{ getSharedSeed :: ByteString
} deriving (Show, Eq, Ord, Generic, NFData, Typeable)

[1] https://github.com/input-output-hk/cardano-sl/blob/master/core/Pos/Core/Types.hs

+6
source share
2 answers

This means "export all constructors and write fields for this data type."

When writing a module export list, there are 4 ways to export a data type:

module ModuleD(
    D,       -- just the type, no constructors
    D(..),   -- the type and all its constructors
    D(DA)    -- the type and the specific constructor
    ) where

data D = DA A | DB B

, , , , , . , , , :

module Even (evenInt, toInt) where

newtype EvenInt = EvenInt Int deriving (Show, Eq)

evenInt :: Int -> Maybe EvenInt
evenInt x = if x `mod` 2 == 0 then Just x else Nothing

toInt :: EvenInt -> Int
toInt (EvenInt x) = x

, :

x = evenInt 2
putStrLn $ if isJust x then show . toInt . fromJust $ x else "Not even!"

toInt :

data EvenInt = EvenInt { toInt :: Int }

4 . @leftaroundabout

+5

/ Haskell. , . , Haskell , . newtype, : SharedSeed :: *, ( ) SharedSeed :: ByteString -> SharedSeed.

, . , , .

. : newtype (. Bartek), .

, , , Maybe. , :

module Pos.Core.Types(
  • SharedSeed (SharedSeed) SharedSeed. , , , , .

  • SharedSeed (..) . , SharedSeed, , , Maybe Nothing, Just.

  • pattern SharedSeed ShareSeed ( ShareSeed). -XPatternSynonyms.

    )
    
+5

All Articles