From c1932d5cd082331df881a5da4c2a4ff281c84d69 Mon Sep 17 00:00:00 2001 From: hsjobeki Date: Tue, 31 Jan 2023 10:06:14 +0100 Subject: [PATCH] improved rendering of types & builtins types --- components/codeHighlight/codeHighlight.tsx | 4 +- components/preview/preview.tsx | 5 +- flake.lock | 6 +- scripts/data/builtins.types.json | 156 +++++++++++---------- 4 files changed, 87 insertions(+), 84 deletions(-) diff --git a/components/codeHighlight/codeHighlight.tsx b/components/codeHighlight/codeHighlight.tsx index 8a9ea78..9157537 100644 --- a/components/codeHighlight/codeHighlight.tsx +++ b/components/codeHighlight/codeHighlight.tsx @@ -28,10 +28,10 @@ export const CodeHighlight = (props: CodeHighlightProps) => { sx={{ "&.MuiBox-root": { width: "100%", - marginTop: 0, + margin: 0, }, "&.MuiBox-root>pre": { - marginTop: 0, + margin: 0, }, "&.MuiBox-root>pre code.hljs": { bgcolor: background || undefined, diff --git a/components/preview/preview.tsx b/components/preview/preview.tsx index 1771182..a81fe13 100644 --- a/components/preview/preview.tsx +++ b/components/preview/preview.tsx @@ -178,8 +178,8 @@ export const Preview = (props: PreviewProps) => { fontSize: 14, }} secondaryTypographyProps={{ - color: fn_type ? "text.primary" : "text.secondary", - fontSize: "1rem", + // color: fn_type ? "text.primary" : "text.secondary", + fontSize: theme.typography.fontSize + 4, }} secondary={ fn_type ? ( @@ -195,6 +195,7 @@ export const Preview = (props: PreviewProps) => { primary="function signature " /> + {console.log({ fn_type })} {example && ( number -> number" }, - "all": { "fn_type": "all :: (a -> bool) -> [a] -> bool" }, - "any": { "fn_type": "any :: (a -> bool) -> [a] -> bool" }, + "abort": { "fn_type": "abort :: String" }, + "add": { "fn_type": "add :: Number -> Number -> Number" }, + "all": { "fn_type": "all :: (a -> Bool) -> [a] -> Bool" }, + "Any": { "fn_type": "Any :: (a -> Bool) -> [a] -> Bool" }, "attrNames": { "fn_type": "attrNames :: AttrSet -> [a]" }, "attrValues": { "fn_type": "attrValues :: AttrSet -> [a]" }, - "baseNameOf": { "fn_type": "baseNameOf :: string -> string" }, - "bitAnd": { "fn_type": "bitAnd :: int -> int -> int" }, - "bitOr": { "fn_type": "bitOr :: int -> int -> int" }, - "bitXor": { "fn_type": "bitXor :: int -> int -> int" }, + "baseNameOf": { "fn_type": "baseNameOf :: String -> String" }, + "bitAnd": { "fn_type": "bitAnd :: Int -> Int -> Int" }, + "bitOr": { "fn_type": "bitOr :: Int -> Int -> Int" }, + "bitXor": { "fn_type": "bitXor :: Int -> Int -> Int" }, "break": { "fn_type": "break :: a -> a" }, - "catAttrs": { "fn_type": "cattAtrs :: string -> [AttrSet] -> [a]" }, - "ceil": { "fn_type": "ceil :: double -> int" }, - "compareVersions": { - "fn_type": "compareVersions :: string -> string -> int" + "catAttrs": { + "fn_type": "cattAtrs :: String -> [ { ${name} :: a } ] -> [a]" }, - "concatLists": { "fn_type": "concatLists :: [list] -> []" }, + "ceil": { "fn_type": "ceil :: Float -> Int" }, + "compareVersions": { + "fn_type": "compareVersions :: String -> String -> Int" + }, + "concatLists": { "fn_type": "concatLists :: [List] -> []" }, "concatMap": { "fn_type": "concatMap :: (a -> b) -> [a] -> [b]" }, "concatStringsSep": { - "fn_type": "concatStringsSep :: string -> [string] -> string" + "fn_type": "concatStringsSep :: String -> [String] -> String" }, "deepSeq": { "fn_type": "deepSeq :: a -> b -> b" }, - "dirOf": { "fn_type": "dirOf :: string -> string" }, - "div": { "fn_type": "div :: number -> number -> number" }, - "elem": { "fn_type": "elem :: a -> [b] -> bool" }, - "elemAt": { "fn_type": "elemAt :: [a] -> int -> b" }, - "fetchClosure": { "fn_type": "fetchClosure :: attrSet -> attrSet" }, - "fetchGit": { "fn_type": "fetchgit :: attrSet -> attrSet" }, - "fetchTarball": { "fn_type": "fetchTarball :: attrSet -> attrSet" }, - "fetchurl": { "fn_type": "fetchurl :: string -> attrSet" }, - "filter": { "fn_type": "filter :: (a -> bool) -> [a] -> [b]" }, + "dirOf": { "fn_type": "dirOf :: String -> String" }, + "div": { "fn_type": "div :: Number -> Number -> Number" }, + "elem": { "fn_type": "elem :: a -> [b] -> Bool" }, + "elemAt": { "fn_type": "elemAt :: [a] -> Int -> b" }, + "fetchClosure": { "fn_type": "fetchClosure :: AttrSet -> AttrSet" }, + "fetchGit": { "fn_type": "fetchgit :: AttrSet -> AttrSet" }, + "fetchTarball": { "fn_type": "fetchTarball :: AttrSet -> AttrSet" }, + "fetchurl": { "fn_type": "fetchurl :: String -> AttrSet" }, + "filter": { "fn_type": "filter :: (a -> Bool) -> [a] -> [b]" }, "filterSource": { - "fn_type": "filterSource :: (path :: string -> type :: string -> bool) -> path -> storePath :: string" + "fn_type": "filterSource :: (Path -> String -> Bool) -> Path -> StorePath" }, - "floor": { "fn_type": "floor :: double -> int" }, + "floor": { "fn_type": "floor :: Float -> Int" }, "foldl'": { - "fn_type": "foldl' :: (acc :: a -> curr :: b -> c) -> init :: a -> [b] -> c" + "fn_type": "foldl' :: (a -> b -> c) -> a -> [b] -> c" }, - "fromJSON": { "fn_type": "fromJSON :: string -> a" }, - "functionArgs": { "fn_type": "functionArgs :: (a) -> attrSet" }, + "fromJSON": { "fn_type": "fromJSON :: String -> a" }, + "functionArgs": { "fn_type": "functionArgs :: (a) -> AttrSet" }, "genList": { "fn_type": "genList :: (a -> b) -> a -> [b]" }, - "genericClosure": { "fn_type": "genericClosure :: attrSet -> [attrSet]" }, - "getAttr": { "fn_type": "getAttr :: string -> attrSet -> a" }, - "getEnv": { "fn_type": "getEnv :: string -> string" }, - "getFlake": { "fn_type": "getFlake :: attrSet -> attrSet" }, - "groupBy": { "fn_type": "groupBy :: (a -> b) -> [a] -> attrSet" }, - "hasAttr": { "fn_type": "hasAttr :: string -> attrSet -> bool" }, - "hashFile": { "fn_type": "hashFile :: string -> path -> string" }, - "hashString": { "fn_type": "hashString :: string -> string -> string" }, + "genericClosure": { "fn_type": "genericClosure :: AttrSet -> [AttrSet]" }, + "getAttr": { "fn_type": "getAttr :: String -> AttrSet -> a" }, + "getEnv": { "fn_type": "getEnv :: String -> String" }, + "getFlake": { "fn_type": "getFlake :: AttrSet -> AttrSet" }, + "groupBy": { "fn_type": "groupBy :: (a -> b) -> [a] -> AttrSet" }, + "hasAttr": { "fn_type": "hasAttr :: String -> AttrSet -> Bool" }, + "hashFile": { "fn_type": "hashFile :: String -> Path -> String" }, + "hashString": { "fn_type": "hashString :: String -> String -> String" }, "head": { "fn_type": "head :: [a] -> a" }, - "import": { "fn_type": "import :: path -> a" }, + "import": { "fn_type": "import :: Path -> a" }, "intersectAttrs": { - "fn_type": "intersectAttrs :: attrSet -> attrSet -> attrSet" + "fn_type": "intersectAttrs :: AttrSet -> AttrSet -> AttrSet" }, - "isAttrs": { "fn_type": "isAttrs :: a -> bool" }, - "isBool": { "fn_type": "isBool :: a -> bool" }, - "isFloat": { "fn_type": "isFloat :: a -> bool" }, - "isFunction": { "fn_type": "isFunction :: a -> bool" }, - "isInt": { "fn_type": "isInt :: a -> bool" }, - "isList": { "fn_type": "isList :: a -> bool" }, - "isNull": { "fn_type": "isNull :: a -> bool" }, - "isPath": { "fn_type": "isPath :: a -> bool" }, - "isString": { "fn_type": "isString :: a -> bool" }, - "length": { "fn_type": "length :: [a] -> int" }, - "lessThan": { "fn_type": "lessThan :: number -> number -> bool" }, + "isAttrs": { "fn_type": "isAttrs :: a -> Bool" }, + "isBool": { "fn_type": "isBool :: a -> Bool" }, + "isFloat": { "fn_type": "isFloat :: a -> Bool" }, + "isFunction": { "fn_type": "isFunction :: a -> Bool" }, + "isInt": { "fn_type": "isInt :: a -> Bool" }, + "isList": { "fn_type": "isList :: a -> Bool" }, + "isNull": { "fn_type": "isNull :: a -> Bool" }, + "isPath": { "fn_type": "isPath :: a -> Bool" }, + "isString": { "fn_type": "isString :: a -> Bool" }, + "length": { "fn_type": "length :: [a] -> Int" }, + "lessThan": { "fn_type": "lessThan :: Number -> Number -> Bool" }, "listToAttrs": { - "fn_type": "listToAttrs :: [{name :: string; value :: a}] -> attrSet" + "fn_type": "listToAttrs :: [{name :: String; value :: a}] -> AttrSet" }, "map": { "fn_type": "map :: (a -> b) -> [a] -> [b]" }, - "mapAttrs": { "fn_type": "mapAttrs :: (a -> b -> c) -> attrSet -> attrSet" }, - "match": { "fn_type": "match :: string -> string -> bool" }, - "mul": { "fn_type": "mul :: number -> number -> number" }, - "parseDrvName": { "fn_type": "parseDrvName :: string -> attrSet" }, - "partition": { "fn_type": "partition :: (a -> bool) -> [a] -> attrSet" }, - "path": { "fn_type": "path :: attrSet -> storePath" }, - "pathExists": { "fn_type": "pathExists :: path -> bool" }, - "placeholder": { "fn_type": "placeholder :: string -> string" }, - "readDir": { "fn_type": "readDir :: path -> attrSet" }, - "readFile": { "fn_type": "readFile :: path -> string" }, - "removeAttrs": { "fn_type": "removeAttrs :: attrSet -> [a] -> attrSet" }, + "mapAttrs": { "fn_type": "mapAttrs :: (a -> b -> c) -> AttrSet -> AttrSet" }, + "match": { "fn_type": "match :: String -> String -> Bool" }, + "mul": { "fn_type": "mul :: Number -> Number -> Number" }, + "parseDrvName": { "fn_type": "parseDrvName :: String -> AttrSet" }, + "partition": { "fn_type": "partition :: (a -> Bool) -> [a] -> AttrSet" }, + "Path": { "fn_type": "Path :: AttrSet -> StorePath" }, + "pathExists": { "fn_type": "pathExists :: Path -> Bool" }, + "placeholder": { "fn_type": "placeholder :: String -> String" }, + "readDir": { "fn_type": "readDir :: Path -> AttrSet" }, + "readFile": { "fn_type": "readFile :: Path -> String" }, + "removeAttrs": { "fn_type": "removeAttrs :: AttrSet -> [a] -> AttrSet" }, "replaceStrings": { - "fn_type": "replaceStrings :: [string] -> [string] -> string -> string" + "fn_type": "replaceStrings :: [String] -> [String] -> String -> String" }, "seq": { "fn_type": "seq :: a -> b -> b" }, - "sort": { "fn_type": "sort :: (a -> b -> bool) -> [a] -> [b]" }, - "split": { "fn_type": "split :: string -> string -> [string]" }, - "splitVersion": { "fn_type": "splitVersion :: string -> [string]" }, - "storePath": { "fn_type": "storePath :: storePath -> storePath" }, - "stringLength": { "fn_type": "stringLength :: string -> int" }, - "sub": { "fn_type": "sub :: number -> number -> number" }, - "substring": { "fn_type": "substring :: int -> int -> string -> string" }, + "sort": { "fn_type": "sort :: (a -> b -> Bool) -> [a] -> [b]" }, + "split": { "fn_type": "split :: String -> String -> [String]" }, + "splitVersion": { "fn_type": "splitVersion :: String -> [String]" }, + "StorePath": { "fn_type": "StorePath :: StorePath -> StorePath" }, + "stringLength": { "fn_type": "stringLength :: String -> Int" }, + "sub": { "fn_type": "sub :: Number -> Number -> Number" }, + "substring": { "fn_type": "substring :: Int -> Int -> String -> String" }, "tail": { "fn_type": "tail :: [a] -> a" }, - "throw": { "fn_type": "throw :: string" }, - "toFile": { "fn_type": "toFile :: path -> string -> storePath" }, - "toJSON": { "fn_type": "toJSON :: a -> string" }, - "toPath": { "fn_type": "toPath :: string -> path" }, - "toString": { "fn_type": "toString :: a -> string" }, - "toXML": { "fn_type": "toXML :: a -> string" }, + "throw": { "fn_type": "throw :: String" }, + "toFile": { "fn_type": "toFile :: Path -> String -> StorePath " }, + "toJSON": { "fn_type": "toJSON :: a -> String" }, + "toPath": { "fn_type": "toPath :: String -> Path" }, + "toString": { "fn_type": "toString :: a -> String" }, + "toXML": { "fn_type": "toXML :: a -> String" }, "trace": { "fn_type": "trace :: a -> b -> b" }, "traceVerbose": { "fn_type": "traceVerbose :: a -> b -> b" }, "tryEval": { "fn_type": "tryEval :: a" }, - "typeOf": { "fn_type": "typeOf :: a -> string" }, + "typeOf": { "fn_type": "typeOf :: a -> String" }, "zipAttrsWith": { - "fn_type": "zipAttrsWith :: (name:: string -> values :: [a]) -> [a] -> attrSet" + "fn_type": "zipAttrsWith :: (String -> [a] ) -> [a] -> AttrSet" } }