Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module defines "type-safe" bindings to some of the UNIX shell tools.
We demonstrate the use of Kleene.Type (and KleenePlugin) to program in Haskell in completely structural way (i.e. non-nominal).
Disclaimer: the fact that we can doesn't mean that we should.
We may define self-proxy types instead of using K
for flags.
Then the usage will be more nice.
However, we don't, to emphasise the point, as in this module we only use
three types:
Example
{-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedLabels #-} {-# OPTIONS_GHC -fplugin=KleenePlugin #-} {-# OPTIONS_GHC -dcore-lint #-} module Main (main) where import Kleene.Type.Examples.KleeneSH main :: IO () main = do (( ls_, #l, ".", #h )) (( find_, #type, #f, "plugin", "src" ))
We get very close to the dynamic feeling, compare to:
(do (ls :l "." :h) (ls :type :f "plugin" "src"))
Synopsis
- ls_ :: REList LS -> IO ()
- type LS = S (V FilePath \/ (Flag "l" \/ Flag "h"))
- find_ :: REList FIND -> IO ()
- type FIND = S FIND'
- type FIND' = V FilePath \/ ((Flag "name" <> V FilePath) \/ (Flag "type" <> TYPES))
- type TYPES = Flag "d" \/ Flag "f"
- true_ :: REList TRUE -> IO ()
- type TRUE = T
- command :: forall re. REInductionC ToArg re => FilePath -> REList re -> IO ()
- type Flag s = V (Key s)
- class ToArg a where
- module Kleene.Type
Commands
ls
find
true
Implementation
:: REInductionC ToArg re | |
=> FilePath | executable |
-> REList re | arguments |
-> IO () |
Convert a
to String
cli-argument.
Re-exports
module Kleene.Type