如何parseModule
使用语言扩展名解析 Haskell 文件?
使用parseModule
from Language.Haskell.Exts
,当我尝试Core.hs
从https://github.com/xmonad/xmonad/blob/master/src/XMonad/Core.hs解析文件时 出现错误:
XGene-exe: fromParseResult: Parse failed at [<unknown>.hs] (248:25): Illegal data/newtype declaration
这似乎是因为它使用了存在类型:
data Layout a = forall l. (LayoutClass l a, Read (l a)) => Layout (l a)
Core.hs
顶部还有语言ExistentialQuantification
扩展编译指示:
{-# LANGUAGE ExistentialQuantification, FlexibleInstances, GeneralizedNewtypeDeriving,
MultiParamTypeClasses, TypeSynonymInstances, DeriveDataTypeable #-}
当我尝试Layout.hs
(https://github.com/xmonad/xmonad/blob/master/src/XMonad/Core.hsParse failed at [<unknown>.hs] (53:1): MultiParamTypeClasses language extension is not enabled. Please add {-# LANGUAGE MultiParamTypeClasses #-} pragma at the top of your module.
)时,尽管存在编译指示,但我得到了错误
:
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, PatternGuards, TypeSynonymInstances, DeriveDataTypeable #-}
Main.hs
尽管Operations.hs
有_Malformed context: FlexibleContexts is not enabled
{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-}
Config.hs
,ManageHook.hs
并Stackset.hs
正确解析。
xmonad 在我进行 cabal 构建时构建。