HaHaHa!(old)

2009-01-10

Haskell でスクリプトを書く

ための簡単なフレームワークのつもり

{-# LANGUAGE MultiParamTypeClasses #-}
module System.Script where

import System.Environment

type Proc   a b  = a -> b
type Input  a    = IO a
type Output a    = a -> IO ()

class Script t a b c where
  mkinput  :: t a b c -> Meta c -> Input  a -- make input   action
  mkoutput :: t a b c -> Meta c -> Output b -- make output  action
  mkproc   :: t a b c -> Meta c -> Proc a b -- make convert function (a -> b)

type Name = String
type Var  = String
type Val  = String
type Env  = [(Var,Val)]
type Arg  = String
type Args = [Arg]
type Msg  = String
type Msgs = [String]

type ParsedArgs a = ([a]   -- parsed options
                    ,Args  -- non-option arguments
                    ,Msgs) -- messages for error during parsing arguments

type ArgsParser a  = Args -> ParsedArgs a

type Meta a = (Name,Env,ParsedArgs a) -- Meta information for script

runScript :: Script t a b c => t a b c -> Meta c -> IO ()
runScript x m = output . proc  =<< input
   where (output, proc, input) = (mkoutput x m, mkproc x m, mkinput x m)

meta :: ArgsParser a ->  IO (Meta a)
meta p = getProgName     >>= \ n ->
         getEnvironment  >>= \ e ->
         getArgs         >>= \ a ->
         return (n,e,p a)

CaiyaCaiya2016/05/10 22:06My fave is the pomegranate, but I have8&#n217;t tried the one you say is your fave. I do have a mint bees’ wax stick that was a hand-me-down from Joel. He hated the minty freshness. They need to invent some kind of compartment so you can keep chapstick in the car without it melting.

RopeRope2016/05/11 19:29As such, it seems to me I need to collect all the <a href="http://tugsewi.com">sortwafe</a> and document the process while I still can, and put it all in one place, both for myself, and for anyone else who wants to keep using this old.

TaimiTaimi2016/05/14 09:38dear <a href="http://wkswziah.com">kri&#in,ist39;m</a> dieying to read Fire. is this book sold in Buenos Aires? i don' care if it is in English, i can read it.please if someone knows, could you tell me?lots of love.

LorenaLorena2016/05/15 07:53Whats cheery fantastically nice website!! Man .. Superb .. Superb .. I’ll bookmark your web situate and acquire the feeds adiolidnatly…I am glad to attain frequent of use in a row here within the situate in the lead, we’d like polish additional strategies in this regard, be grateful you for sharing. . . . . . http://rocznltl.com [url=http://mldverjcyit.com]mldverjcyit[/url] [link=http://lzfetpkj.com]lzfetpkj[/link]