Jay's not-very-efficient implementation of Haskell's functional programming, in C++ (C upcoming).
Very much todo. C++ has priority for now.
For documentation, see c++/docs.md.
HSC++ uses GNU Make/G++ for compilation and compiles down to a shared library (c++/lib/libhsc++.so
).
Features:
- Basic data type wrappers (in namespace
hscpp
):hsInt
(for C/C++'sint
, Haskell'sInt
)hsInteger
(for C/C++'slong
, Haskell'sInteger
)hsBool
(for C/C++'sbool
, Haskell'sBool
)hsFloat
(for C/C++'sfloat
, Haskell'sFloat
)hsDouble
(for C/C++'sdouble
, Haskell'sDouble
)hsChar
(for C/C++'schar
, Haskell'sChar
)
- Show and Read type classes.
- Limitation: due to circular dependencies, the basic data types are not Show. There exists, however, a
show
method that takes any of them and returns ahsString
(string).
- Limitation: due to circular dependencies, the basic data types are not Show. There exists, however, a
- Functor, Applicative and Monad type classes.
- Monadic List (and String wrapper)
- Limitation: due to circular dependencies (partial classes),
List<a>
is not Show, even ifa
is.
- Limitation: due to circular dependencies (partial classes),
- Maybe monad (which is conditionally Show: if
a : Show
, thenMaybe<a> : Show
). - Either monad (which is conditionally Show: if
a : Show
ande : Show
, thenEither<a, e> : Show
)- Limitation:
a
ande
can't name the same type (due to the use of unions).
- Limitation:
Eq
,Ord
,Enum
,Bounded
type classes- Limitation:
Enum
only has the to & from enum, along with succ and pred.
- Limitation:
Makefile targets:
- In
c++/Makefile
:all
: builds the shared library.empty
: shows all source files, the generated object files and their dependency files.examples
: compiles/links the examples; binaries will be inc++/ex/bin/
.tests
: compiles/links the tests; executable will bec++/bin/all
.runtests
: compiles/links the tests, then runs it.clean
: cleans up the make environment (only for the library, doesn't cleanc++/ex/
orc++/test/
).install
: builds the shared library, installs it under/usr/lib/
and installs the header files (c++/inc/
) under/usr/include/hsc/
(requiressudo
).
- In
c++/ex/Makefile
:all
: builds all examples; binaries will be inc++/ex/bin/
.clean
: cleans the examples up.
- In
c++/test/Makefile
: tests aren't set up yet.
Examples:
c++/ex/bin/list
: Simple example showing the monadic List.c++/ex/bin/either
: Simple example showing the Either monad.c++/ex/bin/maybe
: Simple example showing the Maybe monad.