Commit eea58fa9 authored by Mart Lubbers's avatar Mart Lubbers Committed by Camil Staps

Resolve overlapping instances for Text.Unicode; add +++ for lists

parent 0e60cc42
definition module Data.List
from StdClass import class Ord, class Eq, class IncDec
from StdOverloaded import class ==, class <, class length, class %, class toString, class toChar, class fromString, class fromChar, class +, class *, class /, class *, class /, class *, class /, class *, class /, class zero, class one, class -
from StdOverloaded import class ==, class <, class length, class %, class toString, class toChar, class fromString, class fromChar, class +, class *, class /, class *, class /, class *, class /, class *, class /, class zero, class one, class -, class +++
import StdList
from Data.GenEq import generic gEq
......@@ -25,6 +25,8 @@ instance Monoid [a]
instance Foldable []
instance Traversable []
instance +++ [a]
/**
* An element in the list, or Nothing if it does not exist.
*/
......
......@@ -70,6 +70,10 @@ instance Traversable []
where
traverse f x = foldr (\x ys->(\x xs->[x:xs]) <$> f x <*> ys) (pure []) x
instance +++ [a]
where
(+++) a b = a ++ b
(!?) infixl 9 :: ![.a] !Int -> Maybe .a
(!?) [x:_] 0 = Just x
(!?) [_:xs] i = xs !? (i-1)
......
implementation module Text.HTML
import StdEnv
import StdEnv, StdMisc
import Data.Maybe, Data.GenEq
from StdFunc import o
from StdMisc import abort
from Data.List import intersperse
import Data.List
import Text
instance toString HtmlTag
where
......
definition module Text.Unicode
import StdClass
from Text.Unicode.UChar import :: UChar
from StdOverloaded import class +++
from Data.List import instance +++ [a]
:: UString :== [UChar]
// String is supposed be ASCII
instance fromString UString
instance % UString
instance +++ UString
class fromUnicode a :: !UString -> a
class toUnicode a :: !a -> UString
implementation module Text.Unicode
import StdArray, StdInt, StdList
from Text.Unicode.UChar import :: UChar, instance fromChar UChar
instance fromString UString
where
fromString str = [fromChar c \\ c <-: str]
instance % UString
where
(%) str (f,t) = take (t-f+1) (drop f str )
instance +++ UString
where
(+++) str1 str2 = str1 ++ str2
from Text.Unicode.UChar import :: UChar
implementation module Text.Unicode.UChar
import StdEnum, StdClass, StdBool, StdFunc, StdMisc
import StdClass, StdOverloaded, StdBool, StdMisc
import code from "bsearch."
import code from "WCsubst."
......
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