Home
UHC user manual, version 1.1.4 - Department of Information and
Contents
1. coreopt opt core opts pp parseable 2 2 Commandline options Only options offered by UHC are discussed lower variants of UHC have more options for debugging available Other options can be used but are either for internal use of can be disabled sometime Defaults for options are valid only for variant 100 of EHC Boolean options are indicated by Bool where True and False can be indicated by one of 1 yes on respectively O noloff e h help Print commandline help and quit e version Print a longer version description e version dotted Print the version in a dotted format as used by many version aware utilities like cabal e version asnumber Same as version dotted but without the dots the value __UHC__ has when preprocessing with cpp e numeric version See version dotted e v lt level gt verbose lt level gt Verbosity level Verbosity lt level gt s are accumulative in their reported messages 0 quiet 1 default minimal report of compile phases 2 report of compile phases including import handling and similar info 3 progress of internal processing 4 additional debugging info e t lt target gt target lt target gt Generate code for a target Code generation lt target gt s Default bc bc bytecode interpreter based executable See bc backend page 23 C whole program analysis C code based executable See C backend page 23
2. e No cabal support yet 6 7 Partially functional backends 6 7 1 llvm GRIN based LLVM with whole program analysis e For variant 8 only little runtime support 6 7 2 clr GRIN based CLR with whole program analysis e For variant 8 only no runtime support e Only when enabled via configure enable clr 7 Troubleshooting FAQ 7 1 The compiler seems to loop or complains about premature end of file or complains with ehc Prelude chr bad argument 4087767 Remove hi files manually as it seems not to be possible to guarantee that hi files from a previous version or another haskell compiler are detected as invalid 7 2 I have installed UHC previously now the libraries do not compile From a previous install the library path settings may linger around This information is stored in the file reported by uhc meta dir env Volumes Work uhc 101 Remove this directory From version 1 0 1 onwards this should no longer be a problem as the version number is encoded in the filename 24 uhc meta dir env Volumes Work uhc 1 0 1 101 From version 1 1 onwards the above mechanism is not used anymore 7 3 I have checked out a new EHC version over a previously working one and now it does not compile anymore Many things currently change in particular also in the build process so when checking out a new version over an old one old stuff may linger around If you get build errors for a lt variant gt try
3. Int gt Int gt Int gt Int ii3 id3 id3 gets a function to which it must pass a function of type forall a a gt a it is then ok when this function is used as Int gt Int so as a value for ii3 we can use id3 Both of these invocations are therefore legal id3 id2 id3 ii2 id3app1 id3app2 However the other way around fails for passing ii3 a function id2 which then must be given a foralla a gt a ii3app1 ii3app2 ii3 id2 type error ii3 ii2 The mechanism extends to the use of class predicates ieq Eqa gt a gt a ieq id iord Orda gt a gt a iord ieq Similarly for rank 2 we can define ieq2 forall a Eq a gt a gt a gt Int ieq2 iord2 iord2 forall a Ord a gt a gt a gt Int iord2 i i 3 This is ok ieq2 constructs a function accepting an Ord dictionary from the function it gets passed itself which can then be passed to iord2 The compiler provides this coercion automatically Currently this mechanism has limits e Although co and contravariance is propagated and analysed through datatypes coercions are only derived for functions and tuples 3 1 3 Impredicativity UHC allows impredicativity albeit with assistance of a programmer For example in the following example impredicativity means that the type of the argument to single propagates with quantifiers this must be done explicitly by using in front of an argument 10 single forall a a
4. e enable coresysf under construction Enable System F generation for Core e enable cmm under construction Enable Cmm intermediate language for C code generation Replacing enable with disable will have the reverse effect 2 Using UHC 2 1 Commandline invocation As printed by instal1 100 bin ehc help version ehc 1 1 4 revision masterCicb861b398 timestamp 20120928 0200 144218 aspects base hmtyinfer codegen grin n Usage ehc options file ehl hs options h v 011121314 t bc jazyljs p hslehlastl 0 0111213 lt opt gt Bo01 1 i path help version version dotted version asnumber numeric version verbose 0 1121314 target bc jazyljs target flavor debug plain pretty hs eh ast optimise 0 1 2 3 lt opt gt Boo1 no recomp no prelude no hi check compile only import path path print this help then stop print version info then stop print version in x y z style then stop print version in xyz style then stop see version dotted to become obsolete be verbose O quiet 4 debug default 1 generate code for target default bc generate code for target flavor default plain show pretty printed source or EH abstract syntax tree d optimise with level or specific by name default 1 turn off recompilation check force recompile do not assume presence of Prelude no check on hi files not matching the compiler version compile
5. no hi check Don t use out of date of compiler version w r t to hi files as a reason to recompile This is useful when debugging the compiler if you know that hi files will not change Use this option only if you know what you are doing cpp Preprocess with cpp See also preprocessing page 18 limit tysyn expand lt nr gt Limit the level of type synonym expansion i lt path gt import path lt path gt Add lt path gt to the search path for importing modules and cpp odir dir Generated files are put in dir More precisely for each generated artefact for a module the module name with dots replaced by slashes is appended to dir and used as the actual base name When compiling for the construction of a package an additional 4 level directory structure is prefixed encoding package name compiler version target and flavor keep intermediate files Keep intermediate files such as c files and output of cpp meta options These are mostly used to let makefiles know what can be done meta optimizations names of all possible optimizations See also optimizations page meta targets all possible code generation targets meta target default default code generation target meta variant EHC variant meta pkgdir system Print the builtin system dir holding packages and quit meta pkgdir user Same as meta pkgdir system but user dir e pkg options These ar
6. pragmas page 17 e Pattern guards PatternGuards are not implemented 5 Backend specifics 5 1 Foreign function interface FFI 5 1 1 Primitives A limited form of FFI is allowed only to define primitives A special calling convention prim is used to indicate such primitives The calling convention follows the necessary calling convention for the backend for which code is generated For example the Prelude contains foreign import prim primAddInt 32 Int gt Int gt Int 5 1 2 bc and C backend The bc or C based target uses the ccall calling convention the jazy target uses jazy To ensure the use of C calling convention use ccall1 but support depends on the target For example for target bc the Prelude defines foreign import ccall sinf primSinFloat Float gt Float The Foreign XX library modules are available Calling conventions dynamic wrapper export as well as wrapping as finalizers is not yet supported 5 1 3 js backend The js calling convention for the js Javascript backend allows import entities to specify a little bit of OO like notation and array access The subsequent is taken from the UHC blog Haskell s Foreign Function Interface FFI predefined calling conventions do not match well with Javascript s object oriented features In particular selecting a field of an object using dot notation like o f and using an object as an array using brackets like o i do not have a natural counterpart in
7. gt a single x x idsi single id forall a a gt a ids2 single id forall a a gt a For ids2 the type forall a a gt a has been propagated via the argument type variable of single to inside the list For ids1 the argument is first instantiated Alternatively we can enforce this by providing a type signature ids3 single id forall a a gt a ids4 single id forall a a gt a ids5 single forall a a gt a gt forall a a gt a id All these result in the same type as for ids2 Without type signature or use of the type of the argument will not be propagated impredicatively 3 1 4 Caveats e Inference is order sensitive and sometimes difficult to predict characterize const x gt x ids cons2 x gt x ids should be forall a a gt a but is fi cons2 x gt x forall a a gt a ids the extra annotation fixes this e Requires programmer assistance to remedy this 3 2 Standalone deriving instance Deriving clauses for a datatype can be specified independent of a datatype definition The notation follows GHC hence see GHC s documentation on Stand alone deriving declarations 3 3 Generic deriving Instance deriving can be generically specified The mechanism consists of three ingredients specifying deriving behavior binding the behavior to an instance and declaring an instance The latter declaring an instance is done as
8. Haskell or the default calling conventions supported by the FFI interface So here are some examples of how Javascript is accessed in UHC via its jscript calling convention data Document foreign import jscript document document IO Document foreign import jscript 41 write documentWrite Document gt JSString gt IO foreign import jscript alert JSString gt IO From within a browser the document representation can be accessed via the global variable document the foreign entity document translates to a reference to this variable The type of the document is defined as an opaque type it can thus only manipulated via Javascript Writing a string to the 19 document is done by invoking the method write on a document The foreign entity 1 write specifies that from all arguments the first one is used as the receiver of the method write The parenthesis specify that a call has to be made where means passing all arguments except those referred to explicitly by means of lt nr gt where lt nr gt gt 1 refers to argument lt nr gt If an entity is omitted as in alert it defaults to lt functionname gt where lt functionname gt is the name of the foreign function being defined Function documentWrite does not accept a String but a JSString instead defined to be the platform dependent representation of Strings converted to and from String with corresponding conversion functions type JSString
9. PackedString stringToJSString String gt JSString jsStringToString JSString gt String stringToJSString forces its argument to be fully evaluated and then converts it to a Javascript String There is choice whether to put document in the 10 monad or not depending whether this global object itself will ever be assigned a new value or not Not being a Javascript DOM wizard wrapping in IO seems to be the safest bet Given these functions a minimal Hello World web program thus is main alert stringToJSString Hi there As this would pop up an alert box an alternative Hi is the following program which writes to the document instead main do d lt document documentWrite d stringToJSString Hi there Actually the usual Hello would have worked as well because it is implemented as writing to the document main putStr Hi there To show the usefulness of array like access as part of we do a bit of rudimentary DOM programming foreign import jscript 41 getElementsByName documentGetElementsByName Document gt JSString gt IO NodeList Nod data NodeList x foreign import jscript 4 1 length nodeListLength NodeList Node gt Int foreign import jscript 1 2 nodeListItem NodeList Node gt Int gt 10 Node data Node foreign import jscript 1 innerHTML elementInnerHTML Node gt JSString foreign import jscript 1 tagName elementTagName Node gt JSString A NodeList is not an
10. array but behaves like an array we can ask for its length and retrieve an element by index It is not an array itself so modelling it as such in Haskell would be incorrect However by allowing import entities to use Javascript array notation we circumvent this limitation and the Javascript array interface can still be used easily Finally this minimal interface to DOM can be used to retrieve and print info about an element in an html document 20 main do d lt document nl lt documentGetElementsByName d stringToJSString myHeader print nodeListLength nl n lt nodeListItem nl 0 print jsStringToString elementTagName n print jsStringToString elementInnerHTML n Given the presence of lt hi name myHeader gt Head says hello lt h1 gt with the name myHeader in the document where the program is run it will produce the following as part of the document 1 Hi Head says hello For reference import entities follow the following grammar exp Haskell constructor to JS object arg ident post JS expression post ident object field gt exp array indexing C args function call args epsilon arg arg possible arguments arg 2 C int all arguments or a specific one ane str literal text ident a valid JavaScript identifier int any integer str any string where ident is a Haskell like lowercase uppercase identifier and wh
11. in i j The above example respectively prints False and True Instance declarations as well as arising class constraints have a scope associated The Eq constraint for the second i j arose in the context of the local instance for Eq Int which was then used for the context resolution in preference over the one defined globally in the Prelude During context resolution the following rules are used e Whenever a choice between instances is possible the one with the innermost scope in relation to the to be proven constraint is chosen If no such choice is possible because scopes are equal this is considered an overlapping instance e Class constraints over which is quantified lose their scope They can arise in different scopes as part of instantiation in such a different scope Quantified class constraints are not reduced via instances only via superclasses and only when the superclass constraint also arose This is to avoid too early binding associated with a closed world of instances e Being in scope is static that is solely determined by the structure of the program text The implementation still has some quirks when abstracted dictionaries are involved Sticking to ground instances like in the examples avoid this 3 9 Lexically scoped type variables Lexically scoped type variables can be introduced via e pattern type signatures on arguments for example in the following result type and type of an intermediate computati
12. only do not link search path for user files separators appended to L path lib search path path search path for library files see also import path cpp preprocess source with CPP limit tysyn expand lt nr gt type synonym expansion limit odir dir base directory for generated files Implies compile on o file output file file to generate executable to keep intermediate files keep intermediate files default off meta variant meta print variant then stop meta target default meta print the default codegeneration target then stop meta targets meta print supported codegeneration targets then stop meta optimizations meta print optimization names then stop meta pkgdir system meta print system package dir then stop meta pkgdir user meta print user package dir then stop package package see pkg expose hide all packages see pkg hide all pkg build package pkg build package from files Implies compile only pkg expose package pkg expose use package pkg hide package pkg hide package pkg hide all pkg hide all implicitly assumed used packages pkg searchpath path pkg package search directories each dir has lt pkg gt lt var cfg install root dir cfg installation root to be used only by wrapper scrip cfg install variant variant cfg installation variant to be used only by wrapper sc optP opt for cmd opt option for cmd used by compiler currently only P
13. parameter the result type still can be chosen more explanation here The combination with impredicativity can sometimes cause unexpected behavior more explanation here 3 6 Existential types Types can be hidden using existential types using the keyword exists x exists a a xt 3 Int x1 holds an Int but when x1 is used this knowledge is forgotten As a consequence nothing can be done anymore with x1 except passing it to polymorphic functions like id which do not assume anything about the value being passed More useful is the combination with a function accepting a value of the hidden type providing en capsulation and data abstraction x2 exists a a a gt Int x2 3 Int id xapp exists b b b gt a gt a xapp v f fv x2app xapp x2 13 An existential type being bound to a value identifier has meaning in that it fixates the type for the existential The type of x2 is some type invented by the compiler and cannot be named by the programmer This is to prevent illegal mixing up two different existentials while still be able to compute different existentials depending on some input mkx Bool gt exists a a a gt Int mkx b if b then x2 else a ord yi mkx True y1 C_3_225_0_0 C_3_225_0_0 gt Int y2 mkx False y2 C_3_245_0_0 C_3_245_0_0 gt Int mixy let v1 f1 y1 v2 2 y2 in fi v2 mixy causes a type error However
14. target flavor lt flavor gt Generate code for a target Code generation lt flavor gt s De fault plain Flavors distinguish between incompatible ways of generating code This is not yet used except for experimenting with code generation with extra debugging in particular stack tracing plain nothing special debug debugging experiments O lt level gt lt scope gt optimise lt level gt lt scope gt Optimisation level and scope Currently this makes little difference as few optimisations are implemented Levels 0 none 1 default basic 2 much 3 all lt opt gt Boo1 turn on off optimization option lt opt gt on top of those already defined See also meta optimizations optimizations page 8 The scope determines at which point the optimizations are done by default on a per module basis optionally on a whole program by linking in an earlier compiler pipeline stage The linking then only pulls in that what is required and can do the cheaper optimisations on the full program as well 0 per module default 1 link per module GRIN to whole program GRIN and continue from there not yet implemented 2 link per module Core to whole program COre and continue from ther Core precedes GRIN in the compiler pipeline no recomp Don t check for the necessity to recompile recompile allways instead no prelude Don t assume the presence of Prelude
15. the relevant specified type information is propagated to where it is needed Such type information may be freely mixed with tuples poly3 b forall a a gt a gt Int b poly3 b f f 1 f b poly4 b f forall a a gt a f 1 Int f b or type constructors data Tab Tab poly5 T b forall a a gt a gt Int b poly5 Tb f f 1 f b poly6 T b f forall a a gt a f 1 Int f b Quantified types may also be used at arbitrary rank in this case rank 3 poly7 forall a a gt a gt Int Bool gt Int Bool poly7 poly poly id pval poly7 poly1 3 1 2 Co and contravariance With rank co and contravariance swap For example in the following a more general function can be used where a less general is expected id can be used as an implementation for ii iio Int gt Int ii id However the following does not work because the instantiation relation swaps direction on a con travariance position id2 forall a a gt a gt Int id2i i3 ii2 Int gt Int gt Int ii2 id2 type error ii2 cannot pass to id2 a function of type forall a a gt a because it only gets a Int gt Int However the other way around is perfectly ok id2 forall a a gt a gt Int id2 ii2 112 Int gt Int gt Int ii2i i3 This extends to higher ranks as well id3 forall a a gt a gt Int gt Int id3 i i id ii3
16. to fix it with one the following in order of severity e Rerun configure e Clean with make lt variant gt clean e Manually remove the build directory EHCHOME build and the installation directory for building EHCHOME install for build If this does not fix the building send us the full build output 8 License The Utrecht Haskell Compiler UHC License UHC follows the advertisement free BSD license of which the basic template can be found here http www opensource org licenses bsd license php UHC uses the following libraries with their own license Library code from the GHC distribution see comment in the modules in ehclib License text Copyright c 2009 2010 Utrecht University Department of Information and Computing Sciences Software Technology group All rights reserved Redistribution and use in source and binary forms with or without modification are permitted provided that the following conditions are met Redistributions of source code must retain the above copyright notice this list of conditions and the following disclaimer Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED
17. usual by a deriving clause either as part of a datatype definition or as a standalone clause Currently generic deriving is used for classes Eq Bounded Functor and Typeable in the base libraries As an example the code for Bounded from the Prelude is shown here the details datatypes and limitations are explained in the paper A generic deriving mechanism for Haskell As is practice with generic programming programming is done in terms of sum product and unit types data f gp L1 unli f p R1 unR1 gp sum data f gp fp gp product data U1 p U1 unit for products newtype K1 ic p Ki unK1 c wrapper for type constants over which no deriving is do newtype M1 ic f p M1 unM1 f p wrapper for meta information constructor For each datatype instance of Representable0 are generated by the compiler used to convert between the datatype and the generic representation Representable types of kind class RepresentableO a rep where Convert from the datatype to its representation from0 a gt rep x Convert from the representation to the datatype tod 3 rep x gt a 11 The generic programmer is required to do the following e Bounded helper class Generic behavior is defined for a helper class later bound to the real class class Bounded f where minBound f x maxBound f x e Specifying deriving behavior for Bounded instance Bounde
18. 19 5 1 Foreign function interface FFD 2 0 20 oo o 19 gll A A eb ae ee DR A ae we 8 19 5 1 2 be and C backend cio 62 gow ae a Beh aa EE A 19 Old js backend savea eek ee A ee a EN ee ee A oe ee S 19 5 2 Limitations ceso ee a ee dee ee 21 21 a wh a dea we oe Bea ee ara a la ee Moke ae 2 21 eae ease dae gan Gi eee en ee oo a ee sok cg 22 Me eer tela ok Gud Auch eG Be ee a es ee eee ie E 22 NE ge eie Bias Sue gh ee bee hte Peg cee e 22 G 4 Known ISSUES osorno we SS A A we a 23 pt a ee rs as 23 6 5 1 bc GRIN based interpreter no whole program analysis 23 6 6 Almost fully functional backendsS o o o 23 6 6 1 C GRIN based C with whole program analysiS o 23 6 6 2 jazy Core based Java no whole program analysis 24 6 6 3 js Core based JavaScript no whole program analysis 24 AA AA a A AN A 24 6 7 1 llvm GRIN based LLVM with whole program analysis 24 6 7 2 clr GRIN based CLR with whole program analysis 24 7 Troubleshooting FAQ 24 SO 24 7 2 I have installed UHC previously now the libraries do not compile haa a a o ech cee AA 2 25 25 9 Further reading 26 1 Introduction and installation For version 1 1 4 1 1 System overview For now see the UHC structure overview 1 2 Download build install compile and run A separate manual exists on how to install UH
19. C on a Windows system A list of often occurring build problems is maintained 1 2 1 Download e Prerequisites Running the configure scripts yields an overview of what is missing a recent version preferably gt 7 0 3 GHC 7 0 3 has been used for recent develop ment GHC 7 4 1 for current development Older GHC versions may do as well but are not used for developing nor is any effort done for keeping UHC compilable with older GHC versions The installed libraries should include the mt1 and fgl library Depending on platform and GHC distribution more libraries may need to be installed Additional libraries available via or locally parser combinators attribute grammar system e Download See the download page 1 2 2 Build and install UHC e Prerequisites GHC and the abovementioned libraries must be installed Look here for setting up a cygwin environment and additional info on installing UHC under cygwin e For building UHC run the following commands from trunk EHC configure make uhc under the hood this is EHC variant 101 make install sudo may be required depending on your permissions During the build part of the compiler is built as a library installed as a ghc user package via cabal 1 23 Run UHC e Run UHC A sample session cat gt hw hs module HelloWorld where main putStrLn Hello World uhc hw hs 1 1 Compiling Haskell hw hw hs hw Hello World By
20. UHC user manual version 1 1 4 Atze Dijkstra September 28 2012 Contents 1 Introduction and installation 1 1 System overview 1 2 Download build install compile and run P21 Wownload ter esoo iio a a A ds eS ee RA dd A 1 2 2 Build and install UH 123 R n UHC secam aktepe eR a a ia a a 124 Test WAC a si Sole de de eh ta de A dd eR a he dat a A 1 2 5 Troubleshoot 2 ee 1 2 6 More make commands 2 0 a a a a a 1 2 7 Configuration parameters ooa ee ue a pee Mae er Aa BA ae a OEE ee on E peda e ee oe ee ae ee oe nk aoe ae 2 4 Optimizations 2 265468 2565 4 bb ee eee EE a a aa 3 Language extensions 3 1 Higher ranked types and impredicativity 3 1 1 Higher ranked types 3 1 2 Co and contravariance 3 1 3 AMpPredicativity lt q nds eee oe A RE ESR ERE RAS a 10 ZLA Caveats soe fe a Go ee eee eee RA DR ee EES de ee es 11 3 3 Generic deriving a a e as 13 3 8 Local instances 3 9 Lexically scoped type variables 2 2 ee 15 3 10 Extensible records rann m r taa ue E a e a a a a e E 15 3 11 Relaxed monomorphism restriction 2 2 a 16 3 12 Default for ambiguous overloading 3 14 Pragmas 3 15 Preprocessing with cpp 4 Haskell compatibility 18 AL Haskell Igjen ra ee ae Re a RA AV we ee 18 4 2 Haskell 2010 0 aie tke ss aaa BR ee ee we SR RS e 19 oPRWWWNNDNY ND oom on
21. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE DATA OR 25 PROFITS OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 9 Further reading See also with EHC of EHC e Shuffle for manipulating source chunks e Text2Text for documentation formatting 26
22. ags are then defined Unless mentioned otherwise the flags are just defined i e have no value e __UHC__ which has the numerical form of the compiler version as its value See also option version asnumber e __UHC_TARGET_X__ where X stands for the current backend target gt e __UHC_BUILDS_X where X stands for gt 0 when C compilation is done only relevant for C code compilation but cpp is then invoked as part of C compilation CPP when cpp preprocessing is done 4 Haskell compatibility 4 1 Haskell 98 The following Haskell98 features are not or partially supported e N k patterns are not implemented e Bound variables in an irrefutable pattern all are individually irrefutable nested irrefutability is ignored e Literate Haskell allows begin code end code but not individual lines prefixed with gt e Strictness annotation in datatype definitions is allowed but ignored e The monomorphism restriction is implemented in a relaxed variant 18 4 2 Haskell 2010 The following Haskell 2010 features are not or partially supported e The foreign function interface See ForeignFunctionInterface is implemented to the point where base libraries can be constructed In particular export is not implemented and neither are dynamic and wrapper imports The stdcall calling convention is not implemented e Some but not all LANGUAGE pragmas LanguagePragma are recognised others are ignored See
23. case Potentially more subtly problematic however are overloaded bindings inside a tuple or other aggre grates newtype Wrap Wrap Double properFraction RealFrac a Integral b gt a gt b a z Wrap x let my m y properFraction x in m Wrap y If generalized on their own both m and y would be generalized and overloaded losing any typing con nection constraint between them which in turn leads to overgeneralization which leads to unexpected ambiguity On its own the non monomorphically restricted m would have the following type m Integral a gt a This could be fixed by using lexically scoped type variables page 15 z Wrap x mt let m mt y properFraction x in m mt Wrap y but the above is the second reason for enforcing monomorphism for the aggregrate value In the above partial type signatures page 12 were also used 16 3 12 Default for ambiguous overloading Defaulting is implemented following mostly Haskell prime defaulting proposal 2 i e per class default ing is allowed One default can be defined per class e g for class C class C a where ci a gt a instance C Int where c id default C Int Interaction with multiple parameter type classed is unpredictable and should be avoided Defaults cannot be turned off with default The Haskell98 form of default is syntactically allowed but silently ignored Multiple types may be specified currently only the fi
24. d U1 where minBound U1 maxBound U1 instance Bounded fT gt Bounded M1 iT cT fT where minBound Mi minBound maxBound Mi maxBound instance Bounded fT Bounded gT gt Bounded fT gT where minBound minBound minBound maxBound maxBound maxBound instance Bounded fT gt Bounded Ki iT fT where minBound Ki minBound maxBound Ki maxBound instance Bounded fT Bounded gT gt Bounded fT gT where minBound L1 minBound maxBound R1 maxBound e Binding the behavior to derived instances Each generic function requires a Representable0 instance and generic behavior Bounded helper which are tied together with a generic func tion e g minBoundDefault and bound to the derivable function with a DERIVABLE language pragma DERIVABLE Bounded minBound minBoundDefault minBoundDefault RepresentableO aT repT Bounded repT gt repT xT gt aT minBoundDefault rep to0 minBound asTypeOf rep DERIVABLE Bounded maxBound maxBoundDefault maxBoundDefault RepresentableO aT repT Bounded repT gt repT xT gt aT maxBoundDefault rep to0 maxBound asTypeOf rep 3 4 Partial type signature Partial type signatures are fully specified type signatures where parts may be omitted and then later filled in by the type inferencer Partial type signatures offer a middle way b
25. default an executable for code generation target bc bytecode interpreter is generated 1 2 4 Test UHC e Regress test UHC make test WARNING output may differ w r t names for the following tests 102 hs 103 hs make test regress TEST_VARIANTS uhc version 101 99 BoundedChar1 hs exp101 99 BoundedChar1 hs regi01 99 BoundedInt1 hs exp101 99 BoundedInt1 hs reg101 99 CaseFall1 hs exp101 99 CaseFalli hs regi01 Differences may also be reported because of platform dependent representation of linefeeds The tests where this is likely to happen are marked with the word platform to indicate the platform or runtime environment differences 1 2 5 Troubleshoot See the troubleshooting FAQ page 24 1 2 6 More make commands Type make help to see what more can be build UHC make make uhc make install make uninstall make test EHC amp tools make lt n gt ehc make lt n gt ehclib make lt n gt ehclibs make lt n gt rts make lt n gt bare make ruler make shuffle Documentation make help make www make www sync make doc lt d gt pdf Testing make test regress make test expect make benchmark Distribution make uhc dist Cleaning up make lt n gt clean make clean make clean extlibs make helium defaults to make uhc make uhc and library ehc variant 101 make uhc and install globally into usr local lib uhc 1 1 4 possibly needing admin perm
26. e currently used as a simplistic equivalent of ghc pkg to be used only internally by library construction Expect changes here pkg build lt pkg gt build lt pkg gt from generated files Put in current directory of the one specified with odir pkg expose lt pkg gt expose lt pkg gt to be visible so its modules can be imported pkg hide lt pkg gt reverse of pkg expose pkg hide all hide all packages pkg searchpath path additional locations to search for packages e opt lt X gt opt Pass option to command for pass lt X gt Currently only P is implemented that is passing to the preprocessor CPP 2 3 Cabal and packages Cabal version 1 9 3 and higher has support for building libraries with UHC using the flag uhc to cabal Building executables is not yet supported UHC s package mechanism is accessed via com mandline flags for exposing pkg expose and hiding pkg hide packages Package identifiers may include a version number Be aware of the following current limitations e Package disambiguation i e a module resides in multiple packages is done by using the version number higher versions of the same package take precedence over lower versions an unversioned package takes precedence over a versioned one packages available earlier in the package search path take precedence No further disambiguation is done e g module X residing in both package yy and zz will cause unsp
27. ecified behavior There is no mechanism for specifying package names when importing e Only the default backend is supported This is a limitation of cabal which does not yet have builtin infrastructure for dealing with different backends and variants of backends Some missing language features however may stand in the way of faultless library compilation but all should be well if packages only assume package haske1198 part of the distribution Keep in mind that cabal support for this release is new largely untested and works only for libraries Executables cannot yet be build with cabal 2 4 Optimizations Currently few optimizations are implemented apart from the work on whole program analysis Op timizations can be individually turned on and off e GrinLocal non whole program analysis grin optimizations to remove the most obvious ineffi ciencies e StrictnessAnalysis in development strictness analysis based on relevance analysis 3 Language extensions Bear in mind that these extensions are all but tried and tested 3 1 Higher ranked types and impredicativity 3 1 1 Higher ranked types Higher ranked types are specified explicitly poly1 forall a a gt a gt Int Bool poly1 f f 1 f True Alternatively the type information can be specified without a separate type signature by mixing annotations throughout patterns and expressions poly2 f forall a a gt a f 1 Int f True In both cases
28. ere parenthesis only may appear at the end See also The Utrecht Haskell Compiler JavaScript Backend Page 5 2 Limitations 6 Language implementation status An older overview can be found on older pages on the and language features 6 1 Included packages The following packages are included and precompiled When marked with version 1 0 0 0 it has no relationship with the real hackage package providing just enough for package haske1198 other version numbers mean the same functionality is offered unless specified otherwise e uhcbase version same as compiler version e base version 3 0 0 0 which is arbitrary The C backend only has a minimal System IO which propagates to the haske1198 package e array version 1 0 0 0 e filepath version 1 1 0 4 e oldlocale version 1 0 0 2 21 6 2 oldtime version 1 0 0 4 unix version 1 0 0 0 directory version 1 0 0 0 random version 1 0 0 2 haskel198 version 1 0 1 1 lacking System Cmd system handicapped as described by base package Library modules The library consists of UHC specific modules tightly coupled with the underlying implementation The names of these modules start with UHC Modules from the GHC distribution used without changes Modules cloned adapted from the GHC distribution This maybe involve a couple of ifdefs or more extensive changes The intention is to have these changes merged back into the GHC library as to avoid library difference
29. etween e Fully specifying a signature This can be difficult for complex types e Not specifying a signature at all The type inferencer may then not be able to infer a type The idea is to provide just enough information so that the type inferencer can figure out the rest This is convenient when a signature involves higher ranked types which the type inferencer can not infer on its own f1 forall a a gt a gt f1 i i a i True 12 The dots stand for a wildcard the part to be filled in by the type inferencer which then infers type forall a a gt a gt Char Bool A wildcard can also be given a name like any type variable in a type expression To differentiate it from normal type variables the prefix is used which indicates that the type expression should not be quantified over this type variable f1 forall a a gt a gt b Giving a name to a wildcard is only useful when referred to from another part of the signature f1 forall a a gt a gt b b f1 i i a i True Both elements of the tuple are enforced to have the same type in the example this leads to a type error 3 5 Quantifier position inference If left unspecified the position of a quantifier not automatically is placed in front of a type For example the type signature unsafeCoerce a gt b is interpreted to be unsafeCoerce forall a a gt forall b b The idea is that after passing a
30. hc E cleanup for variant lt n gt cleanup all variants internal libraries and tools cleanup external libraries make all compiler ehc versions make Typing Our Programs library make Lazy Virtual Machine library make Helium library make Haddock documentation for Helium Top and Lvm in hdoc make lt n gt infer2pass make lt n gt grini make lt n gt hdoc make grinis 1 2 7 Configuration parameters make infer2pass demo version lt n gt in bin where lt n gt in 1 2 3 make grin interpreter variant lt n gt in bin where lt n gt in 8 9 10 11 12 13 14 15 17 18 19 20 make Haddock documentation for variant lt n gt in hdoc make all grin interpreter grini versions Apart from the usual options the configure accepts the following options enabling a particular feature Unless mentioned otherwise the default is no e enable java Enable jazy backend e enable jscript Enable jscript Javascript backend Default yes e enable 11vm implies wholeprogAnal wholeprogC Enable 11vm backend e enable clr implies wholeprogAnal wholeprogC Enable clr backend e enable tycore Enable TyCore typed core intermediate representation e enable tauphi implies tycore Enable TyCore based experimental strictness optimiza tions e enable wholeprogC implies wholeprogAnal Enable the C whole program analysis backend e enable wholeprogAnal Enable whole program analysis
31. he stack is hardcoded overflow is runtime checked Almost fully functional backends 6 6 1 C GRIN based C with whole program analysis The HPT analysis is sensitive to particular generated code constructs especially when related to foreign functions Some libraries when used therefore make compilation fail No exceptions throwing an exception will stop the program Runs simple programs using the Prelude only primitives for many of the other libraries are not yet implemented Not all modules available for the bc backend are supported in particular those interacting with the underlying system IO CPUTime The size of the stack is hardcoded No runtime overflow check is done 23 6 6 2 jazy Core based Java no whole program analysis e Only when enabled via configure enable java e Runs for latest variant but partial implementation of required primitives e No exceptions e Jar files and created class files all together get big Code is not causing this but the tables holding constants referring to other classes JVM expects this to be done per class file Because all functions and CAFs have a separate class definition this becomes quite costly in terms of jar file size and runtime startup time 6 6 3 js Core based JavaScript no whole program analysis e Available by default no configure flag to turn it off on e Runs for latest variant but all FFI related to the usual OS stuff is not available e No exceptions yet
32. i uninstall uhc possibly needing admin permission regress test uhc make compiler variant lt n gt in bin where lt n gt in 1234567 89 10 11 12 13 14 15 17 18 make ehc library i e used to compile with ehc variant lt n gt in bin where lt n gt in 99 100 make ehc libraries for all codegen targets make only the rts part of a library make bare source dir for variant lt n gt in bare then cd to there and make make ruler tool make shuffle tool print this help make www documentation doc shuffle doc pdf doc text2text doc pdf doc howtodoc doc pdf doc h install www documentation in the EHC web http www cs uu nl wiki Ehc WebHome make public documentation lt d gt where lt d gt in ruler doc ehc book ehc doc or non public lt d gt in flops06 ruler paper flops06 ruler popl07 explimpl hw06 impred esop or doc lt d gt in shuffle doc text2text doc howtodoc doc howtoexperiment doc ehc technical only if text src available otherwise already generated run regression test restrict to versions lt v gt by specifying TEST_VARIANTS lt v gt default 1 2345678910 11 requires corresponding ehc grini ehclib already built make expected output for later comparison with test regress see test regress for remarks run 16 nofib programs with 3 compilers on 3 inputs each make platform specific binary distribution from uhc build in Volumes Work Programming u
33. ing in hi files takes time Executables for code generation target bc get quite large the C encoding of bytecode files for modules is rather inefficient and linking together with the base libraries draws in most of the library code Large expressions involving many class constraints take non lineair compile time consumed by context reduction When compiling with option cpp or language pragma CPP the file preprocessed by cpp is put in the same directory as the source file Without write permission this will fail Overlapping instances are not reported as such but indirectly by producing an error that a class constraint could not be proven Local instances are not always working properly Stick to its use without abstraction i e only ground instances as in the examples page 14 Regression testing may report differences because of different linefeed encoding on different platforms Instances for tuples are currently limited to at most 5 tuples Also not all standard classes have definitions for tuples in particular Read Resulting code does not execute fast Yes we know many standard optimizations are not yet implemented and the whole program analysis backends require those optimizations as well to be effective Whole program analysis takes a lot of time Fully functional backends 6 5 1 bc GRIN based interpreter no whole program analysis This is the default backend and the most complete 6 6 The size of t
34. n on off overloaded strings default is off See also GHC doc The current difference is that the module Data String is brought in scope although qualified and only for fromString ExtensibleRecords turn on special syntax for extensible records Available for internal backwards compatibility but otherwise useless as codegeneration and runtime currently does not support extensible records It reserves the operators and for record selection and update respectively e DERIVING class field generic function pragma see generic deriving page 11 e EXCLUDE_IF_TARGET targets file header pragma make the module invisible for com pilation This is a hopefully temporary measure to deal with the abilities of distinctive backend For example the js Javascript backend does not support e g file access e OPTIONS_UHC file header pragma provide compiler options as a string to be parsed as if it were passed via the commandline Other or unsupported pragmas are silently ignored even when appropriate currently no warning will be given The text inside the pragma delimiters is then treated as normal comment as were it inside plain and comment delimiters 3 15 Preprocessing with cpp With LANGUAGE pragma CPP defined or option cpp specified source text will be preprocessed by cpp before compilation With option optP additional options passed to cpp may be given The following compile time fl
35. on are connected z Wrap x mt let m mt y properFraction x in m mt Wrap y e pattern type signatures on a function result as in the following zZzabc E e type variables occurring in instance declarations as in the following for a and b instance Sup a b a b c Widen a O a b gt Sup a O a b c where downcast o case widen o Maybe a b of Just r gt downcast r Nothing gt Nothing 3 10 Extensible records Code generation for extensible records is not supported hence no documentation is currently available 15 3 11 Relaxed monomorphism restriction UHC does feature a relaxed form of the monomorphism restriction only bindings to non variable pattern are enforced to be monomorphic So for example for variable bindings like x 1 the type Num a gt a is inferred for x This overloading and loss of sharing can be avoided by using a type signature x Int x 1 or 1 Int ES i Monomorphism however is enforced for bindings to a pattern xi 1 2 Num a gt a x20 x2a _ x1 Integer A first reason for monomorphism currently is pragmatic because in principle the definition of x2a is equivalent to x2a head x1 Numa gt a That is the need for a Num a propagates to fields of an aggregrate value Automatic propagation of these required predicates is not done automatically in UHC hence the monomorphism restriction in this
36. rst one is used default C Int Integer Scope of default definitions is global that is once imported somewhere on an import chain always imported thereby having the same behavior as instance declarations w r t scope This may change in the future The prelude defines default Num Integer default Real Integer default Enum Integer default Integral Integer default Fractional Double default RealFrac Double default Floating Double default RealFloat Double 3 13 Infix type constructors classes and type variables UHC allows type constructors classes and type variables to be operators and to be written infix as does GHC See e g GHC s documentation on Infix type constructors classes and type variables 3 14 Pragmas UHC allows pragmas wrapped inside special commentlike delimiters and e g LANGUAGE CPP The following pragmas are supported e LANGAUGE pragma file header pragmas where pragma may be CPP switch on cpp preprocessing See also preprocessing page 18 NoImplicitPrelude don t automatically import Prelude and or assume its presence GenericDeriving NoGenericDeriving turn on off respectively generic deriving default is on BangPatterns NoBangPatterns turn on off respectively bang patterns default is on PolyKinds NoPolyKinds turn on off respectively polymorphic kind inference default is off 17 OverloadedStrings NoOverloadedStrings tur
37. s between Haskell implementations Modules taken from In due time the intention is to build as much as possible with cabal sharing as much as possible with hackage There are several known problems in the uhcbase and base package 6 3 Data Typeable cast and variants always yields Nothing Equality of type representations is not done efficiently with hashing not yet available but with the usual structural comparison of the type representation Foreign Ptr Weak etc garbage collection related functionality is influenced by the use of Boehm GC e g only a minimal interface for weak pointers finalizers etc is available not doing very much Using functions that works with the internal structure of a handle eg Prelude print inside a weak pointer finalizer will cause the program to crash Nested calls of the internal function UHC Handle withHandle will cause the program to fail Library runtime The C based backends C bc use the following public domain libraries 6 3 1 Third party libraries e LibTomMath has been cloned and adapted to play nicely with the garbage collector 22 6 4 6 5 Known issues Stacksize for the C backend is fixed and not checked for overflow Error messages involving types are difficult to decode too much of the internals of the type system machinery is exposed Compilation of a single module which uses many imports directly or indirectly takes noticably more time because read
38. we can use y1 and y2 perfectly well main 10 main do putStrLn show xapp y1 putStrLn show xapp y2 The invented types for bound existentials are allowed to be used everywhere their use is limited by the availability of functions existentially hidden together with the existential type Existential types can even be used in a manner parallel to laziness on the value level f forall a a gt exists b b a b gt b gt Int f i 3 i main print let b a g f b in gba The b and its type are known after the invocation of f but is immediately passed back as an argument to f enforcing both value and type of a to be the same as that of b Existential types do not work with e Class instances to be hidden together with the existential 3 7 Kind inference and signatures Unknown kinds of type constructors do not default to kind instead they lead to polymorphic kinds data Eq a b Eq forall f f a gt f b Eq Forall a a gt a gt If a more restrictive kind for Eq is desired this can be enforced by a kind signature similar to type signatures for values Eq gt gt 3 8 Local instances Instances can be declared locally eqInt Int gt Int gt Bool eqInt main I0 14 main do let i 3 Int j 6 te Int putStrLn show i j putStrLn show let m 2 Int instance Eq Int where x y eqInt x mod m y mod m
Download Pdf Manuals
Related Search
Related Contents
取付説明書 取扱説明書 - M 必ず、取扱説明書を読みましょう!!! LG WM2601HW Energy Guide Bogart 7 Bedienungsanleitung - MacroSystem Digital Video AG DM240XR Firmware Upgrade Procedure AN208 english analogue quartz watch chronograph User's Guide and Reference Manual Copyright © All rights reserved.
Failed to retrieve file