diff options
author | Ben Gamari <ben@smart-cactus.org> | 2017-01-30 19:21:54 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-01-31 18:50:21 -0500 |
commit | cb4b4fe916b0a704ce0c43f263173b12bd9d98ca (patch) | |
tree | 3012dd19c131a90f59e5f99ea1f9a769cd4ee4ca | |
parent | b3576ed22570364f917c620a3cd29709355e4d51 (diff) | |
download | haskell-cb4b4fe916b0a704ce0c43f263173b12bd9d98ca.tar.gz |
users guide: Fix markup of COMPLETE pragma examples
-rw-r--r-- | docs/users_guide/glasgow_exts.rst | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 9df6ffb511..cf809013f6 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -12838,23 +12838,21 @@ get the best of both worlds, we can choose one as our implementation and then provide a set of pattern synonyms so that users can use the other representation if they desire. We can then specify a ``COMPLETE`` pragma in order to inform the pattern match checker that a function which matches on both ``LeftChoice`` -and ``RightChoice`` is total. +and ``RightChoice`` is total. :: -:: - - data Choice a = Choice Bool a + data Choice a = Choice Bool a - pattern LeftChoice :: a -> Choice a - pattern LeftChoice a = Choice False a + pattern LeftChoice :: a -> Choice a + pattern LeftChoice a = Choice False a - pattern RightChoice :: a -> Choice a - pattern RightChoice a = Choice True a + pattern RightChoice :: a -> Choice a + pattern RightChoice a = Choice True a - {-# COMPLETE LeftChoice, RightChoice #-} + {-# COMPLETE LeftChoice, RightChoice #-} - foo :: Choice Int -> Int - foo (LeftChoice n) = n * 2 - foo (RightChoice n) = n - 2 + foo :: Choice Int -> Int + foo (LeftChoice n) = n * 2 + foo (RightChoice n) = n - 2 ``COMPLETE`` pragmas are only used by the pattern match checker. If a function definition matches on all the constructors specified in the pragma then the @@ -12872,23 +12870,22 @@ to match on all the patterns if the types were inconsistent. The result type must also be unambiguous. Usually this can be inferred but when all the pattern synonyms in a group are polymorphic in the constructor -the user must provide a type signature. +the user must provide a type signature. :: -:: - class LL f where - go :: f a -> () + class LL f where + go :: f a -> () - instance LL [] where - go _ = () + instance LL [] where + go _ = () - pattern T :: LL f => f a - pattern T <- (go -> ()) + pattern T :: LL f => f a + pattern T <- (go -> ()) - {-# COMPLETE T :: [] #-} + {-# COMPLETE T :: [] #-} - -- No warning - foo :: [a] -> Int - foo T = 5 + -- No warning + foo :: [a] -> Int + foo T = 5 .. _overlap-pragma: |