File: DataAbstract.hs

package info (click to toggle)
haskell-derive 2.5.16-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 460 kB
  • sloc: haskell: 3,686; makefile: 5
file content (62 lines) | stat: -rw-r--r-- 2,815 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{-|
    For deriving Data on abstract data types.
-}
module Data.Derive.DataAbstract(makeDataAbstract) where
{-
import Data.Data(Data(..))

example :: Custom

instance Typeable a => Data (Sample a) where
    gfoldl k r x = r x
    gunfold = error "Data.gunfold not implemented on abstract data type: Sample"
    toConstr = error "Data.gunfold not implemented on abstract data type: Sample"
    dataTypeOf = error "Data.gunfold not implemented on abstract data type: Sample"

-}

import Data.Derive.DSL.HSE

-- GENERATED START

import Data.Derive.DSL.DSL
import Data.Derive.Internal.Derivation

makeDataAbstract :: Derivation
makeDataAbstract = derivationCustomDSL "DataAbstract" custom $
    List [Instance ["Typeable"] "Data" (List [App "InsDecl" (List [App
    "FunBind" (List [List [App "Match" (List [App "Ident" (List [
    String "gfoldl"]),List [App "PVar" (List [App "Ident" (List [
    String "k"])]),App "PVar" (List [App "Ident" (List [String "r"])])
    ,App "PVar" (List [App "Ident" (List [String "x"])])],App
    "Nothing" (List []),App "UnGuardedRhs" (List [App "App" (List [App
    "Var" (List [App "UnQual" (List [App "Ident" (List [String "r"])])
    ]),App "Var" (List [App "UnQual" (List [App "Ident" (List [String
    "x"])])])])]),App "BDecls" (List [List []])])]])]),App "InsDecl" (
    List [App "PatBind" (List [App "PVar" (List [App "Ident" (List [
    String "gunfold"])]),App "Nothing" (List []),App "UnGuardedRhs" (
    List [App "App" (List [App "Var" (List [App "UnQual" (List [App
    "Ident" (List [String "error"])])]),App "Lit" (List [App "String"
    (List [Concat (List [String
    "Data.gunfold not implemented on abstract data type: ",DataName])]
    )])])]),App "BDecls" (List [List []])])]),App "InsDecl" (List [App
    "PatBind" (List [App "PVar" (List [App "Ident" (List [String
    "toConstr"])]),App "Nothing" (List []),App "UnGuardedRhs" (List [
    App "App" (List [App "Var" (List [App "UnQual" (List [App "Ident"
    (List [String "error"])])]),App "Lit" (List [App "String" (List [
    Concat (List [String
    "Data.gunfold not implemented on abstract data type: ",DataName])]
    )])])]),App "BDecls" (List [List []])])]),App "InsDecl" (List [App
    "PatBind" (List [App "PVar" (List [App "Ident" (List [String
    "dataTypeOf"])]),App "Nothing" (List []),App "UnGuardedRhs" (List
    [App "App" (List [App "Var" (List [App "UnQual" (List [App "Ident"
    (List [String "error"])])]),App "Lit" (List [App "String" (List [
    Concat (List [String
    "Data.gunfold not implemented on abstract data type: ",DataName])]
    )])])]),App "BDecls" (List [List []])])])])]
-- GENERATED STOP

custom = customContext context

context :: FullDataDecl -> Context -> Context
context d _ = [ClassA (qname t) [tyVar x] | x <- dataDeclVars $ snd d, t <- ["Typeable","Data"]]