我有以下文件,它是一个基于堆栈的脚本:
#!/usr/bin/env stack
-- stack --resolver lts-12.5 script --package protolude
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Newton where
import Protolude hiding (repeat)
next n x = (x + n / x ) / 2
repeat f a = a : repeat f (f a)
within eps (a:b:rest) = if abs (a - b) <= eps then b
else within eps (b:rest)
sqrt a0 eps n = within eps (repeat (next n) a0)
main = (print @IO) $ take 10 $ repeat (next 2) (5 :: Float)
-- >>> take 10 $ repeat (next 2) (5 :: Float)
基于对环境的独立描述,是否有办法进行错误/类型检查的“ Haskell模式”?
是否有一个轻巧的“新建”或nix替代产品可以给我带来好处?