Verified Commit 20bc5a9e authored by Camil Staps's avatar Camil Staps 🙂

Add FunctionKind

parent 0e0c05c7
......@@ -11,6 +11,8 @@ from StdOverloaded import class zero, class fromString, class toString,
from Data.Maybe import :: Maybe
from Text.JSON import generic JSONEncode, generic JSONDecode, :: JSONNode
from GenEq import generic gEq
/**
* A Cloogle request
*/
......@@ -42,10 +44,9 @@ from Text.JSON import generic JSONEncode, generic JSONDecode, :: JSONNode
* A single Cloogle result
*/
:: Result
= FunctionResult FunctionResult //* A normal function, generic, class member, constructor or record field
= FunctionResult FunctionResult //* A normal function, macro, generic, class member, constructor or record field
| TypeResult TypeResult //* A type definition
| ClassResult ClassResult //* A class definition
| MacroResult MacroResult //* A macro
| ModuleResult ModuleResult //* A module
/**
......@@ -70,11 +71,21 @@ from Text.JSON import generic JSONEncode, generic JSONDecode, :: JSONNode
*/
:: FunctionResult :== (BasicResult, FunctionResultExtras)
/**
* Different kind of Clean functions
*/
:: FunctionKind
= Function //* A normal function or generic
| Macro //* A macro
| Constructor //* An ADT constructor
| RecordField //* A record field
/**
* Function-specific Cloogle result data
*/
:: FunctionResultExtras
= { func :: String //* A string representation of the type
, kind :: FunctionKind //* The kind of function
, unifier :: Maybe StrUnifier //* A unifier, if the request included a type
, cls :: Maybe ShortClassResult //* The class, if this is a class member
, constructor_of :: Maybe String //* The type that this is a constructor of
......@@ -207,11 +218,12 @@ instance toInt CloogleError
instance fromInt CloogleError
derive JSONEncode Request, Response, Result, ShortClassResult, BasicResult,
FunctionResultExtras, TypeResultExtras, ClassResultExtras,
FunctionResultExtras, TypeResultExtras, ClassResultExtras, FunctionKind,
MacroResultExtras, ModuleResultExtras, StrUnifier
derive JSONDecode Request, Response, Result, ShortClassResult, BasicResult,
FunctionResultExtras, TypeResultExtras, ClassResultExtras,
FunctionResultExtras, TypeResultExtras, ClassResultExtras, FunctionKind,
MacroResultExtras, ModuleResultExtras, StrUnifier
derive gEq FunctionKind
instance zero Request
instance zero Response
......@@ -223,3 +235,5 @@ instance fromString (Maybe Request)
instance < BasicResult
instance < Result
instance == FunctionKind
implementation module Cloogle
import StdOverloaded
from Data.Func import $
import Text
import Text.JSON
import GenEq
derive JSONEncode Request, Response, Result, ShortClassResult, BasicResult,
FunctionResultExtras, TypeResultExtras, ClassResultExtras,
FunctionResultExtras, TypeResultExtras, ClassResultExtras, FunctionKind,
MacroResultExtras, ModuleResultExtras, StrUnifier
derive JSONDecode Request, Response, Result, ShortClassResult, BasicResult,
FunctionResultExtras, TypeResultExtras, ClassResultExtras,
FunctionResultExtras, TypeResultExtras, ClassResultExtras, FunctionKind,
MacroResultExtras, ModuleResultExtras, StrUnifier
derive gEq FunctionKind
instance toInt CloogleError
where
......@@ -68,5 +73,6 @@ where
basic (FunctionResult (br,_)) = br
basic (TypeResult (br,_)) = br
basic (ClassResult (br,_)) = br
basic (MacroResult (br,_)) = br
basic (ModuleResult (br,_)) = br
instance == FunctionKind where == a b = a === b
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment