packages feed

indexed-do-notation (empty) → 0.1

raw patch · 4 files changed

+87/−0 lines, 4 filesdep +basedep +haskell-src-metadep +indexedsetup-changed

Dependencies added: base, haskell-src-meta, indexed, template-haskell

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2013, Fumiaki Kinoshita
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * Neither the name of Fumiaki Kinoshita nor the names of other
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Language/Haskell/IndexedDo.hs view
@@ -0,0 +1,33 @@+{-# LANGUAGE TemplateHaskell #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Language.Haskell.IndexedDo
+-- Copyright   :  (C) 2013 Fumiaki Kinoshita
+-- License     :  BSD-style (see the file LICENSE)
+--
+-- Maintainer  :  Fumiaki Kinsohita <fumiexcel@gmail.com>
+-- Stability   :  experimental
+-- Portability :  non-portable
+--
+----------------------------------------------------------------------------
+module Language.Haskell.IndexedDo (ido) where
+
+import Control.Monad.Indexed
+
+import Language.Haskell.Meta
+import Language.Haskell.TH
+import Language.Haskell.TH.Quote
+
+ido :: QuasiQuoter
+ido = QuasiQuoter { quoteExp = \str -> case parseExp str of
+        Right (DoE ss) -> return (go ss)
+        Right _ -> fail "Expecting do notation"
+        Left err -> fail (show err)
+        , quotePat = undefined
+        , quoteType = undefined
+        , quoteDec = undefined
+        } where
+    go [NoBindS e] = e
+    go (BindS p e : ss) = VarE 'ibind `AppE` LamE [p] (go ss) `AppE` e
+    go (NoBindS e : ss) = VarE 'ibind `AppE` LamE [WildP] (go ss) `AppE` e
+    go (LetS ds : ss) = LetE ds (go ss)
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple
+main = defaultMain
+ indexed-do-notation.cabal view
@@ -0,0 +1,22 @@+name:                indexed-do-notation
+version:             0.1
+synopsis:            Do notation for indexed monads
+description:         A quasiquoter of indexed do notation. The only thing you have to do is to enclose an ordinary do notation in [ido|...|].
+homepage:            https://github.com/fumieval/indexed-do-notation
+license:             BSD3
+license-file:        LICENSE
+author:              Fumiaki Kinoshita
+maintainer:          Fumiaki Kinoshita <fumiexcel@gmail.com>
+copyright:           Copyright (C) 2013 Fumiaki Kinoshita
+category:            Language
+build-type:          Simple
+cabal-version:       >=1.8
+
+source-repository head
+  type: git
+  location: https://github.com/fumieval/indexed-do-notation.git
+
+library
+  exposed-modules:     Language.Haskell.IndexedDo
+
+  build-depends:       base ==4.*, indexed < 0.2, haskell-src-meta >= 0.6, template-haskell >= 2.7