The 7.8-rc2 User Guide for rebindable syntax includes:
Arrow notation (see Section 7.16, Arrow notation ) uses whatever arr,
(), first, app, (|||) and loop functions are in scope. But unlike the
other constructs, the types of these functions must match the Prelude types
very closely. Details are in flux; if you want to use this, ask!
I want to use this: my types for the functions apparently do not match the
Prelude types closely enough.
Whom should I ask about this?
Thanks very much.
-Nick
- Further Context
If I do something similar with Monad and RebindableSyntax, it type-checks.
I'm doing some experimentation for work. I'd like to index my arrows as
follows.
(Disclaimer: I have not yet considered any of the laws; I do not currently
intend to support `app' and |||.)
infixr 1 ,
type family (:*:) (i :: Maybe *) (j :: Maybe *) :: Maybe *
type instance Nothing :*: j = j
type instance i :*: Nothing = i
type instance Just i :*: Just j = Just (i,j)
returnA :: IArrow arr = arr Nothing a a
returnA = arr id
-- second, ***, and can have the standard default definitions
class IArrow (arr :: Maybe * - * - * - *) where
arr :: (b - c) - arr Nothing b c
() :: arr i a b - arr j b c - arr (i :*: j) a c
first :: arr i b c - arr i (b,d) (c,d)
Unfortunately, the following does not type-check with -XArrows and
-XRebindableSyntax.
diagram :: IArrow arr = arr f x fx - arr g x gx - arr (f :*: g) x gx
diagram f g = proc x - do
fx - f - x
gx - g - x
returnA - gx
The error messages indicate that the type-checker is attempting to unify
the types of f, g, returnA, and the entire proc block.
However, the copy-and-pasted desugaring of that code *does* type-check (mutatis
mutandi).
This S data type is an example of an IArrow.
data S i a b where
SN :: ( a- b ) - S Nothing a b
SJ :: s - ((a,s) - (b,s)) - S (Just s) a b
In terms of the S type, the objective of IArrow is to allow each box in
the diagram to have its own state.
___
ghc-devs mailing list
ghc-devs@haskell.org
http://www.haskell.org/mailman/listinfo/ghc-devs