mirror of
https://github.com/rgleichman/glance.git
synced 2024-11-27 03:02:44 +03:00
Add compose to tutorial.
This commit is contained in:
parent
bef2208939
commit
958611dde3
@ -253,3 +253,41 @@ factorial x =
|
||||
if x == 0
|
||||
then 1
|
||||
else factorial (x - 1) * x
|
||||
|
||||
{- Bonus section:
|
||||
|
||||
The depth of an icon's application tree is called the nesting depth.
|
||||
For example, The icon representing "factorial (x - 1) * x" above has a nesting
|
||||
depth of 3.
|
||||
|
||||
To reduce nesting depth, Glance has an icon that represents an argument applied
|
||||
to a composition of functions.
|
||||
|
||||
For example:
|
||||
y = f (g x)
|
||||
-}
|
||||
y = f (g x)
|
||||
|
||||
{-
|
||||
Glance figures out automatically when to use the compose icon in order to
|
||||
reduce the nesting depth.
|
||||
|
||||
For example, if we slightly rewrite the factorial function above, Glance
|
||||
uses a compose icon for the else expression.
|
||||
|
||||
To enable the compose icon, we change the expression
|
||||
factorial (x - 1) * x
|
||||
to
|
||||
x * factorial (x - 1)
|
||||
|
||||
Notice that the nesting level has been reduced from 3 to 2.
|
||||
|
||||
--factorial x =
|
||||
-- if x == 0
|
||||
-- then 1
|
||||
-- else x * factorial (x - 1)
|
||||
-}
|
||||
factorial x =
|
||||
if x == 0
|
||||
then 1
|
||||
else x * factorial (x - 1)
|
||||
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 355 KiB After Width: | Height: | Size: 399 KiB |
12
todo.txt
12
todo.txt
@ -1,27 +1,27 @@
|
||||
-- TODO Now --
|
||||
Add compose to the tutorial.
|
||||
|
||||
-- TODO Later --
|
||||
-- Add documentation.
|
||||
|
||||
-- Testing todos:
|
||||
Fix the arrowheads being too big for SyntaxGraph darwings.
|
||||
Fix the arrowheads being too big for SyntaxGraph drawings.
|
||||
|
||||
-- Visual todos:
|
||||
-- Make an icon font/library with labeled ports. E.g. the apply icon would have text labels "function", "result", "arg 0", "arg 1", etc.
|
||||
-- Don't rotate text and nested icons, give them rectangualar bounding boxes in GraphViz. (Perhaps use a typeclass for isRotateAble)
|
||||
-- Don't rotate text and nested icons, give them rectangular bounding boxes in GraphViz. (Perhaps use a typeclass for isRotateAble)
|
||||
-- Give lines a black border to make line crossings easier to see.
|
||||
-- Give lines that cross the border of a lambda function a special color.
|
||||
-- Line intersections should have a small circle. This could probably be done with
|
||||
-- a line ending.
|
||||
-- Let each bool, value pair in Guard icon be flipped to reduce line crossings. Do the same for case.
|
||||
-- Let lines connect to ports in multiple locations (eg. case value, or guard result)
|
||||
-- Use different line styles (eg. dashed, solid, wavy) in addition to colors
|
||||
-- Let lines connect to ports in multiple locations (e.g. case value, or guard result)
|
||||
-- Use different line styles (e.g. dashed, solid, wavy) in addition to colors
|
||||
|
||||
-- Translate todos:
|
||||
Fix applyComposeScore in Translate.hs not counting expressions that nest via reference. May need to move compose generation to after translate.
|
||||
|
||||
-- Fix test case x of {0 -> 1; y -> y}.
|
||||
-- Add proper RecConstr, and RecUpdate support.
|
||||
-- Eliminate BranchIcon in Alts.
|
||||
-- Eliminate BranchIcon for the identity funciton "y x = x"
|
||||
-- Eliminate BranchIcon for the identity function "y x = x"
|
||||
-- Special case for otherwise.
|
||||
|
Loading…
Reference in New Issue
Block a user