So, I played with the definition of the TrieSet data type (although I know I do not need it ):
module Temp where import Data.Map data TrieSet a = Nonterminal (Data.Map a (TrieSet a)) | Terminal (Data.Map a (TrieSet a)) insert :: Ord a => [a] -> TrieSet a -> TrieSet a insert [] (_ m) = Terminal m insert (a:as) (cm) = c $ insertWith (insert as . flip const) a (insert as $ Nonterminal empty) m
When I received an error that I had never seen before:
% ghc -c Temp.hs Temp.hs:8:11: Parse error in pattern
So, it seems that the GHC does not like to map multiple unary constructors to the same template. I did another test to make sure this is a problem:
module Temp2 where extract :: Either String String -> String extract (_ s) = s
Which seemed to confirm my suspicion:
% ghc -c Temp2.hs Temp2.hs:4:9: Parse error in pattern
So my question (in several parts):
- Am I right why the GHC does not like these features?
- Any reason why this will not be part of the Haskell standard? In the end, we can map multiple constructors to the same template.
- Is there a LANGUAGE pragma that I can give the GHC to accept?
source share