Skip to content

Instantly share code, notes, and snippets.

@Javran
Created February 26, 2021 09:58
Show Gist options
  • Save Javran/ac02edfe611b8dd88e9aae0699f77eff to your computer and use it in GitHub Desktop.
Save Javran/ac02edfe611b8dd88e9aae0699f77eff to your computer and use it in GitHub Desktop.
Listing Exercism problems not yet ported to Haskell
#!/usr/bin/env stack
{- stack
script
--resolver lts-16.31
--package containers
--package http-client
--package http-client-tls
--package zip-archive
-}
module Main
( main
)
where
import qualified Codec.Archive.Zip as Zip
import Control.Monad
import Data.List
import qualified Data.Set as S
import Network.HTTP.Client
import Network.HTTP.Client.TLS
problemSpecSrc :: String
problemSpecSrc = "https://github.com/exercism/problem-specifications/archive/main.zip"
haskellSpecSrc :: String
haskellSpecSrc = "https://github.com/exercism/haskell/archive/main.zip"
getPracticeSet :: Manager -> String -> FilePath -> IO (S.Set String)
getPracticeSet mgr url magic = do
req <- parseRequest url
resp <- httpLbs req mgr
let raw = responseBody resp
arc = Zip.toArchive raw
fSet = S.fromList $ do
x <- Zip.filesInArchive arc
guard $ magic `isPrefixOf` x
let y = takeWhile (/= '/') $ drop (length magic) x
guard $ not (null y)
pure y
pure fSet
main :: IO ()
main = do
mgr <- newManager tlsManagerSettings
hsSet <- getPracticeSet mgr haskellSpecSrc "haskell-main/exercises/practice/"
specSet <- getPracticeSet mgr problemSpecSrc "problem-specifications-main/exercises/"
let missing = S.difference specSet hsSet
mapM_ print missing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment