Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
Documentation
_NaturalDigits :: Prism' (NonEmpty DecDigit) Natural Source #
>>>
_NaturalDigits # 0
DecDigit0 :| []
>>>
_NaturalDigits # 1
DecDigit1 :| []
>>>
_NaturalDigits # 922
DecDigit9 :| [DecDigit2,DecDigit2]
>>>
(DecDigit9 :| [DecDigit2,DecDigit2]) ^? _NaturalDigits
Just 922
>>>
(DecDigit1 :| []) ^? _NaturalDigits
Just 1
\x -> digitsToNatural ( naturalToDigits x ) == Just x
naturalToDigits :: Natural -> NonEmpty DecDigit Source #
>>>
naturalDigits 0
DecDigit0 :| []
>>>
naturalDigits 9
DecDigit9 :| []
>>>
naturalDigits 393
DecDigit3 :| [DecDigit9,DecDigit3]
digitsToNatural :: NonEmpty DecDigit -> Maybe Natural Source #
Create a number from a list of digits with the integer bounds of the machine.
>>>
digitsToNatural (DecDigit3 :| [DecDigit4])
Just 34
>>>
digitsToNatural (DecDigit0 :| [])
Just 0
>>>
digitsToNatural (naturalToDigits (maxBound :: Natural))
Just 9223372036854775807
>>>
digitsToNatural (naturalToDigits $ (maxBound :: Natural) + 1)
Nothing