From 261d1c62642f0bed3aba3d3601d6df1b93c0d98a Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Sat, 9 Mar 2024 02:52:59 +0100 Subject: [PATCH] seems to work... --- app/Main.hs | 8 ++++++++ flake.lock | 12 ++++++------ twin.cabal | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index a64364c..437629a 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,8 +1,10 @@ module Main where +import System.IO import System.Directory import Options.Applicative import Data.List +import Control.Exception data CgiState = CgiSuccess instance Show CgiState where @@ -76,3 +78,9 @@ mkIndex True d f = in do line <- trim . words . head . lines <$> readFile path putStrLn $ "=> " ++ path ++ " " ++ line + +getFirstLine :: FilePath -> IO (Maybe String) +getFirstLine f = (Just <$> readFile f) `catch` handler + where + handler :: IOException -> IO (Maybe String) + handler _ = return Nothing diff --git a/flake.lock b/flake.lock index fd370fb..3cc22cb 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "owner": "numtide", "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1690753480, - "narHash": "sha256-GQgPs8fCh/LsyQoYMUZgT2p7jFVWyHu9p+1Nl/dp8GY=", + "lastModified": 1705273882, + "narHash": "sha256-68z5kaLaJ3fMWVwnknEKWypElq6Jzgtc9hddd14LhAo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9e06dd56947c1dc3dc837c3149bfe02c71a6edd7", + "rev": "5614bd58587f1337aca11d7b2bdfcca4ca44fccc", "type": "github" }, "original": { diff --git a/twin.cabal b/twin.cabal index 0b6272a..4b257df 100644 --- a/twin.cabal +++ b/twin.cabal @@ -67,7 +67,7 @@ executable twin -- other-extensions: -- Other library packages from which modules are imported. - build-depends: base ^>=4.16.4.0, directory, optparse-applicative + build-depends: base ^>=4.17.2.1, directory, optparse-applicative -- Directories containing source files. hs-source-dirs: app