Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion parsnip/parsnip.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ common base
c-sources: cbits/parsnip.c
build-depends:
attoparsec,
base >= 4.15 && < 5,
base >= 4.12 && < 5,
bytestring,
containers,
data-default,
Expand Down
27 changes: 26 additions & 1 deletion parsnip/src/Text/Parsnip/Internal/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,24 @@
{-# language UnboxedTuples #-}
{-# language MagicHash #-}
{-# language PatternSynonyms #-}

#if __GLASGOW_HASKELL__ >= 810
{-# language UnliftedNewtypes #-}
#endif

{-# options_ghc -O2 #-}

module Text.Parsnip.Internal.Parser
(
-- * Parser
Parser(..)
, Option(Option#,Some,None)
#if __GLASGOW_HASKELL__ >= 810
, Option(Option#, Some, None)
#else
, Option
, pattern Some
, pattern None
#endif
, mapOption, setOption
, Result, pattern OK, pattern Fail
, mapResult, setResult
Expand Down Expand Up @@ -67,6 +77,9 @@ import Text.Parsnip.Internal.Private
--------------------------------------------------------------------------------

-- | Unlifted 'Maybe'

#if __GLASGOW_HASKELL__ >= 810

newtype Option a = Option# (# a | (##) #)

pattern Some :: a -> Option a
Expand All @@ -75,6 +88,18 @@ pattern Some a = Option# (# a | #)
pattern None :: Option a
pattern None = Option# (# | (##) #)

#else

type Option a = (# a | (##) #)

pattern Some :: a -> Option a
pattern Some a = (# a | #)

pattern None :: Option a
pattern None = (# | (##) #)

#endif

{-# complete Some, None #-} -- these don't work outside this module =(

mapOption :: (a -> b) -> Option a -> Option b
Expand Down
1 change: 0 additions & 1 deletion parsnip/src/Text/Parsnip/Internal/Private.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
{-# language BangPatterns #-}
{-# language ViewPatterns #-}
{-# language UnliftedFFITypes #-}
{-# language UnliftedNewtypes #-}

-- | the proverbial junk drawer
module Text.Parsnip.Internal.Private
Expand Down