Since things change so fast, I've posted this question so hopefully the community-agreed way to start a Haskell project can be clarified. Imagine I have two separate projects:
Project #1: Square, the library that squares numbers. No deps.
-- Square.hs module Square where square :: Num a => a -> a square x = x * x
Project #2: Hypotenuse, the library and executable that finds the longest side of a right-angled triangle. Depends on #1:
-- Hypotenuse.hs module Hypotenuse where import Square hypotenuse :: Floating a => a -> a -> a hypotenuse x y = sqrt $ square x + square y
,
-- Main.hs import System.Environment import Hypotenuse main = do [x,y] <- fmap (map read) getArgs print $ hypotenuse x y
Starting with a computer with GHC 7.10.2, Stack and Cabal installed, and a single directory, ~/OrganizeMe
, containing ~/OrganizeMe/Square.hs
, ~/OrganizeMe/Hypotenuse.hs
and ~/OrganizeMe/Main.hs
, as presented above - what is a complete set of unix commands an experienced Haskeller would use to architect those projects? That includes:
Organizing the directory tree of those projects;
configuring
Stack
/Cabal
/etc
(andgit
, optionally);building/installing them locally;
publishing to
Hackage
/Stackage
.