gpt4 book ai didi

haskell - 在 Haskell 中导入模块

转载 作者:行者123 更新时间:2023-12-01 07:53:03 25 4
gpt4 key购买 nike

对于我刚刚开始的 Haskell 项目,我有两个文件 Main.hsLib.hs
然而,我经常发现自己在寻找一些我在 Lib 中导入的模块。在 Main 工作时.

有没有办法自动加载Main.hs Lib 中已经导入的所有模块?

Lib.hs

import System.Random
import Data.List

{-
Lib code here
-}

Main.hs
import Lib -- Importing should automatically imports System.Random and Data.List
main = undefined

最佳答案

模块可以导出其他模块,包括它们自己(这意味着它们导出所有顶级定义,而不是您需要依赖的显式符号列表)。

module Lib ( module System.Random, module Data.List, module Lib) where
import System.Random
import Data.List

{-
Lib code here
-}

关于haskell - 在 Haskell 中导入模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39442964/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com