是否可以使用Template Haskell定义函数?例如
convertStringToValue :: String -> Int
convertStringToValue "three" = 3
convertStringToValue "four" = 4
Run Code Online (Sandbox Code Playgroud)
我也有Map [Char] Int.
fromList [("five",5),("six",6)]
Run Code Online (Sandbox Code Playgroud)
我该如何添加功能
convertStringToValue "six" = 6
convertStringToValue "five" = 5
Run Code Online (Sandbox Code Playgroud)
在编译时使用Template Haskell和Map?使用Template Haskell来达到这个目的似乎很愚蠢,但我还是想知道.