This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import System.Console.CmdArgs.Explicit | |
| main :: IO () | |
| main = do | |
| let flags = [Flag ["l","lj"] FlagReq (\s -> Right . (s:)) "type" "fooo"] | |
| arguments :: Mode [String] | |
| arguments = mode "foobar" [] "helpy" (Arg (const Right) "ff" False) flags | |
| xs <- processArgs arguments | |
| print $ helpText [] HelpFormatDefault arguments | |
| mapM_ putStrLn xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| main :: IO () | |
| main = do | |
| let files :: O.Parser [String] | |
| files = O.helper <*> O.arguments1 (Just) (O.metavar "logfile" <> O.help "one or several log files") | |
| foo = some $ O.strOption | |
| ( O.long "output" | |
| <> O.short 'o' | |
| <> O.metavar "FILENAME" ) | |
| parserInfo = O.info ((,) <$> files <*> foo) (O.fullDesc) | |
| prefs = O.prefs O.showHelpOnError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| streams :: forall f. Functor f => ((StdStream,StdStream,StdStream) -> f (StdStream,StdStream,StdStream)) -> CreateProcess -> f CreateProcess | |
| streams f c = setStreams c <$> f (getStreams c) | |
| where | |
| getStreams c = (std_in c,std_out c, std_err c) | |
| setStreams c (s1,s2,s3) = c { std_in = s1 | |
| , std_out = s2 | |
| , std_err = s3 | |
| } | |
| pipe3 :: (StdStream,StdStream,StdStream) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :t view (_Unwrapping fromList) [('a','b')] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- view | |
| getConst . _env Const $ shell "foo.bat" | |
| -- over | |
| runIdentity . _1 (Identity . (+1)) $ (1,1) | |
| -- a fold (?) | |
| getConst . _Nothing (\x -> Const [x]) $ Just 'a' | |
| -- a prism (?) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :m + System.Process System.Process.Streaming Control.Concurrent.Async | |
| :set prompt # | |
| let z = (async (execute (proc "gvim" []) show $ separate purge purge)) >>= \a -> threadDelay (10^6) >> cancel | |
| a <- async $ execute (proc "gvim" []) show $ separate purge purge | |
| cancel a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- http://www.reddit.com/r/haskell/comments/1z8wsv/prove_your_haskell_for_great_safety_part_i/cfrqwdf | |
| -- http://hackage.haskell.org/package/monomorphic-0.0.3.0/docs/Data-Type-Monomorphic.html | |
| fromList :: [a] -> Monomorphic (Vector a) | |
| fromList [] = Monomorphic Nil | |
| fromList (x : xs) = | |
| case fromList xs of | |
| Monomorphic vs -> Monomorphic $ x :- vs | |
| readVector :: Read a => String -> Monomorphic (Vector a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE OverloadedStrings #-} | |
| import Data.Monoid | |
| import Data.AdditiveGroup | |
| import qualified Data.ByteString as B | |
| import qualified Data.ByteString.Builder as BB | |
| import qualified Data.ByteString.Lazy as BL | |
| --import Data.Time.Clock | |
| import Data.Thyme.Clock | |
| import Data.Thyme.Clock.POSIX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.function.Function; | |
| public class Main { | |
| public Main() { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using Npgsql; | |
| using CommandLine; | |
| using CommandLine.Text; | |
| // http://commandline.codeplex.com/ | |
| namespace Project1 |