モジュールのインポートで苦戦
日付処理を試そうとこんなプログラムを書きました。
import Data.Time main = do putStr $ show $ fromGregorian 2008 1 2
コンパイルしたらこんな結果。
>ghc -W fromGregorian.hs fromGregorian.o(.text+0xbe):fake: undefined reference to `timezm1zi1zi2zi0_DataziTimeziCalendarziGregorian_zdf1_closure' fromGregorian.o(.text+0x17c):fake: undefined reference to `timezm1zi1zi2zi0_DataziTimeziCalendarziGregorian_fromGregorian_closure' fromGregorian.o(.text+0x30b):fake: undefined reference to `__stginit_timezm1zi1zi2zi0_DataziTime_' fromGregorian.o(.data+0x18):fake: undefined reference to `timezm1zi1zi2zi0_DataziTimeziCalendarziGregorian_zdf1_closure' fromGregorian.o(.data+0x48):fake: undefined reference to `timezm1zi1zi2zi0_DataziTimeziCalendarziGregorian_fromGregorian_closure' collect2: ld returned 1 exit status
コンパイルは通っているのに、その後のリンクで失敗しています。ネットで検索してもすぐにはどうしたらよいか分からず、いろいろ調べた結果--makeオプションの存在に気が付きました。
>ghc --make -W fromGregorian.hs
これで無事リンクも成功。こんなところでつまずいている人はあまりいないみたいですね。