diff options
| author | krangelov <kr.angelov@gmail.com> | 2019-02-20 13:00:51 +0100 |
|---|---|---|
| committer | krangelov <kr.angelov@gmail.com> | 2019-02-20 13:00:51 +0100 |
| commit | 64a2483b12f17e98160a5974a3015a54629de480 (patch) | |
| tree | 2eeb17ee16f78acb55f93d81cde0d1c70c5459aa /src/runtime/haskell-bind | |
| parent | 1d1e65185a88928a1066efbcf071ee528529136c (diff) | |
added Data.Data.Data instance for Expr
Diffstat (limited to 'src/runtime/haskell-bind')
| -rw-r--r-- | src/runtime/haskell-bind/PGF2/Expr.hsc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/runtime/haskell-bind/PGF2/Expr.hsc b/src/runtime/haskell-bind/PGF2/Expr.hsc index 096d15bfa..85e55ab40 100644 --- a/src/runtime/haskell-bind/PGF2/Expr.hsc +++ b/src/runtime/haskell-bind/PGF2/Expr.hsc @@ -6,7 +6,9 @@ import System.IO.Unsafe(unsafePerformIO) import Foreign hiding (unsafePerformIO) import Foreign.C import Data.IORef +import Data.Data import PGF2.FFI +import Data.Maybe(fromJust) -- | An data type that represents -- identifiers for functions and categories in PGF. @@ -42,6 +44,20 @@ instance Eq Expr where e1_touch >> e2_touch return (res /= 0) +instance Data Expr where + gfoldl f z e = z (fromJust . readExpr) `f` (showExpr [] e) + toConstr _ = readExprConstr + gunfold k z c = case constrIndex c of + 1 -> k (z (fromJust . readExpr)) + _ -> error "gunfold" + dataTypeOf _ = exprDataType + +readExprConstr :: Constr +readExprConstr = mkConstr exprDataType "(fromJust . readExpr)" [] Prefix + +exprDataType :: DataType +exprDataType = mkDataType "PGF2.Expr" [readExprConstr] + -- | Constructs an expression by lambda abstraction mkAbs :: BindType -> CId -> Expr -> Expr mkAbs bind_type var (Expr body bodyTouch) = |
