add instance deriving instructions
This commit is contained in:
parent
f6c252d314
commit
99a2b0ba09
|
@ -1,4 +1,5 @@
|
||||||
{-# LANGUAGE DataKinds #-}
|
{-# LANGUAGE DataKinds #-}
|
||||||
|
{-# LANGUAGE DerivingStrategies #-}
|
||||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{- |
|
{- |
|
||||||
|
@ -84,7 +85,7 @@ idBits = 256
|
||||||
--
|
--
|
||||||
-- for being able to check value bounds, the constructor should not be used directly
|
-- for being able to check value bounds, the constructor should not be used directly
|
||||||
-- and new values are created via @toNodeID@ (newtype constructors cannot be hidden)
|
-- and new values are created via @toNodeID@ (newtype constructors cannot be hidden)
|
||||||
newtype NodeID = NodeID { getNodeID :: Integer } deriving (Eq, Show, Enum)
|
newtype NodeID = NodeID { getNodeID :: Integer } deriving stock (Show, Eq) deriving newtype Enum
|
||||||
|
|
||||||
-- |smart data constructor for NodeID that throws a runtime exception for out-of-bounds values.
|
-- |smart data constructor for NodeID that throws a runtime exception for out-of-bounds values.
|
||||||
-- When needing a runtime-safe constructor with drawbacks, try @fromInteger@
|
-- When needing a runtime-safe constructor with drawbacks, try @fromInteger@
|
||||||
|
|
Loading…
Reference in a new issue