Commit 110fd636 authored by Camil Staps's avatar Camil Staps 🍃

Cleanup, readme and license

parent 669fdc17
definition module Cache
from StdOverloaded import class toString
from Data.Maybe import :: Maybe
from Text.JSON import generic JSONEncode, generic JSONDecode, :: JSONNode
:: CacheType = Brief | LongTerm
:: CacheKey :== String
cacheKey :: (a -> CacheKey) | toString a
// Check if for the hash of the argument a JSON file exists of type b
readCache :: !a *World -> (Maybe b, !*World) | toString a & JSONDecode{|*|} b
// Write for the hash of a a JSON file of type b
writeCache :: CacheType !a !b -> *World -> *World | toString a & JSONEncode{|*|} b
implementation module Cache
import StdFunc
import StdTuple
from Data.Func import $
import Control.Monad
import Control.Applicative
import Data.Functor
import Crypto.Hash.MD5
import Text.JSON
import Data.Error
import StdFile
import System.FilePath
import System.File
import Data.Tuple
cache_types :== [Brief, LongTerm]
cache_dir :: CacheType -> FilePath
cache_dir LongTerm = "./cache/lt"
cache_dir Brief = "./cache/brief"
cacheKey :: (a -> CacheKey) | toString a
cacheKey = md5 o toString
toCacheFile :: CacheType -> a -> FilePath | toString a
toCacheFile t = (</>) (cache_dir t) o cacheKey
readCache :: !a *World -> (Maybe b, !*World) | toString a & JSONDecode{|*|} b
readCache k w
# (files,w) = seqList [appFst error2mb o readFile (toCacheFile t k) \\ t <- cache_types] w
= (join $ fromJSON <$> fromString <$> foldl (<|>) empty files, w)
writeCache :: CacheType !a !b -> *World -> *World | toString a & JSONEncode{|*|} b
writeCache t k v = snd o writeFile (toCacheFile t k) (toString $ toJSON v)
The MIT License (MIT)
Copyright (c) <2016> <Mart Lubbers and Camil Staps>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
BIN:=CloogleServer builddb
DB=types.json
MAN:=builddb.1 # Others don't have --help/--version # $(addsuffix .1,$(BIN))
CLM:=clm
CLMFLAGS:=-dynamics -h 200M -nr -nt\
-I $$CLEAN_HOME/lib/ArgEnv\
-I $$CLEAN_HOME/lib/Dynamics\
-I $$CLEAN_HOME/lib/Generics\
-I $$CLEAN_HOME/lib/TCPIP\
-I clean-platform/src/libraries/OS-Independent\
-I clean-platform/src/libraries/OS-Independent/Deprecated/StdLib\
-I clean-platform/src/libraries/OS-Linux-64\
-I clean-platform/src/libraries/OS-Linux\
-I clean-platform/src/libraries/OS-Posix\
-I CleanTypeUnifier\
-I CleanPrettyPrint\
-I clean-compiler/frontend\
-I clean-compiler/backend\
-I clean-compiler/main\
-I clean-compiler/main/Unix
.SECONDARY: $(PRJ)
.PHONY: all clean distclean
all: $(BIN) $(DB)
clean-compiler:
svn checkout -r 2746 https://svn.cs.ru.nl/repos/clean-compiler/branches/itask/ clean-compiler
$(MAKE) -j -C clean-compiler/main/Unix
$(MAKE) -j -C clean-compiler/backendC/CleanCompilerSources -f Makefile.linux64
ln -s ../../backendC/CleanCompilerSources/backend.a clean-compiler/backend/Clean\ System\ Files/backend_library
man: $(MAN)
%.1: %
help2man -N ./$< > $@
$(BIN): clean-compiler .FORCE
$(CLM) $(CLMFLAGS) $@ -o $@
$(DB): builddb
./$< > $(DB)
clean:
$(RM) -r 'Clean System Files' $(BIN) $(MAN) $(DB)
distclean: clean
$(RM) -r clean-compiler
.FORCE:
# Cloogle
This is the core system of [Cloogle][], the [Clean][] language search engine.
The source code of the web frontend is in
[clean-cloogle/cloogle.org](https://github.com/clean-cloogle/cloogle.org).
## Structure
The type database is a Clean data structure that can be stored on the disk
using generic JSON encode and decode functions. The functions in `TypeDB`
provide low-level access to modify the database and search in it.
The `TypeDBFactory` module hooks into the Clean compiler to provide functions
to populate a type database by parsing Clean source code.
The functions in `Search` provide a higher level API to the type database,
using the common Cloogle types defined in
[libcloogle](https://github.com/clean-cloogle/libcloogle).
## Copyright &amp; License
Copyright &copy; Mart Lubbers and Camil Staps.
Licensed under MIT; See the `LICENSE` file.
[Clean]: http://clean.cs.ru.nl
[Cloogle]: https://cloogle.org
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