g-ford / cradle Goto Github PK
View Code? Open in Web Editor NEWLet's Build a Compiler (in Haskell)
License: Other
Let's Build a Compiler (in Haskell)
License: Other
In the "Single Digit Math" Chapter:
module Data.Char
should be replaced withimport Data.Char
.Num Int
, but it is instantiated with a Char
in isDigit x = Num x
.Num Int
to Num Char
or construct it with the ordinal value of the character: isDigit x = Num ((ord x)-(ord '0'))
Maybe not that important in general, but for someone not proficient in haskell like me, it took a while to find why the codes are not compiling.
function created to compute expression :
expression (x:y:z:[]) = (term x) ++ (addOperation y) ++ (term z)
shows a type error
• Couldn't match expected type ‘[Char]’ with actual type ‘Char’
• In the second argument of ‘(++)’, namely ‘(term z)’
In the second argument of ‘(++)’, namely
‘(addOperation y) ++ (term z)’
In the expression: (term x) ++ (addOperation y) ++ (term z)
|
17 | expression (x:y:z:[]) = (term x) ++ (addOperation y) ++ (term z)
| ^^^^^^
Possible but immature(imo) solution(or hack) that I came up with is
expression (x:y:z:[]) = (term x : []) ++ (addOperation y) ++ (term z : [])
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.